Class: FullNamePatternValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- FullNamePatternValidator
- Defined in:
- app/validators/full_name_pattern_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 6 |
# File 'app/validators/full_name_pattern_validator.rb', line 2 def validate_each(record, attribute, value) if value.nil? || !value.squeeze(" ").strip.match(/\A\S+?\s\S+?\Z/i) record.errors[attribute] << "First & Last names separated by a space" end end |