Parent

Methods

Class/Module Index [+]

Quicksearch

DataMapper::Validations::FormatValidator

@author Guy van den Berg @since 0.9

Constants

FORMATS

Public Class Methods

new(field_name, options = {}) click to toggle source
# File lib/dm-validations/validators/format_validator.rb, line 20
def initialize(field_name, options = {})
  super

  set_optional_by_default
end

Public Instance Methods

call(target) click to toggle source
# File lib/dm-validations/validators/format_validator.rb, line 26
def call(target)
  return true if valid?(target)

  value = target.validation_property_value(field_name)

  error_message = (
    @options[:message] || ValidationErrors.default_error_message(
      :invalid, field_name
    )
  )

  add_error(
    target,
    error_message.try_call(humanized_field_name, value),
    field_name
  )
  false
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.