Class: ActiveModel::Validations::NumberPlateValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::NumberPlateValidator
- Defined in:
- lib/number_plate_validator/active_model.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/number_plate_validator/active_model.rb', line 4 def validate_each(record, attribute, value) country = case([:country]) when Proc [:country].call(record) when Symbol record.send([:country]) else [:country] end val = ::NumberPlateValidator.validator(country) record.errors.add attribute, ([:message] || "is not a valid number plate") unless val.is_valid?(value) end |