Methods

Class/Module Index [+]

Quicksearch

DataMapper::Validations::NumericalityValidator

@author Guy van den Berg @since 0.9

Public Instance Methods

call(target) click to toggle source
# File lib/dm-validations/validators/numeric_validator.rb, line 7
def call(target)
  value = target.validation_property_value(field_name)
  return true if optional?(value)

  errors = []

  validate_with(integer_only? ? :integer : :numeric, value, errors)

  add_errors(target, errors)

  # if the number is invalid, skip further tests
  return false if errors.any?

  [ :gt, :lt, :gte, :lte, :eq, :ne ].each do |validation_type|
    validate_with(validation_type, value, errors)
  end

  add_errors(target, errors)

  errors.empty?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.