Class: DataMapper::Validate::NumericValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/ixtlan/monkey_patches.rb

Instance Method Summary collapse

Instance Method Details

#validate_with_comparison(value, cmp, expected, error_message_name, errors, negated = false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/ixtlan/monkey_patches.rb', line 25

def validate_with_comparison(value, cmp, expected, error_message_name, errors, negated = false)
  return if expected.nil?
  if cmp == :=~
      return value =~ expected
  end
  comparison = value.send(cmp, expected)
  return if negated ? !comparison : comparison

  errors << ValidationErrors.default_error_message(error_message_name, field_name, expected)
end