Skip to content

Instantly share code, notes, and snippets.

@mkristian
Created November 20, 2009 14:27
Show Gist options
  • Save mkristian/239534 to your computer and use it in GitHub Desktop.
Save mkristian/239534 to your computer and use it in GitHub Desktop.
if RUBY_PLATFORM =~ /java/
module DataMapper
module Validate
class NumericValidator
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
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment