class ActiveModel::Validations::NumberPlateValidator
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/number_plate_validator/active_model.rb, line 4 def validate_each(record, attribute, value) country = case(options[:country]) when Proc options[:country].call(record) when Symbol record.send(options[:country]) else options[:country] end val = ::NumberPlateValidator.validator(country) record.errors.add attribute, (options[:message] || "is not a valid number plate") unless val.is_valid?(value) end