Class: ParanoidStarlight::Validators::NameValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ParanoidStarlight::Validators::NameValidator
- Defined in:
- lib/paranoid_starlight/validators.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/paranoid_starlight/validators.rb', line 17 def validate_each(record, attribute, value) fullname = '\p{Letter}+(-\p{Letter}+)*' surname = fullname short = '\p{Letter}\.' unless value =~ /\A(?:#{fullname} ((#{fullname}|#{short}) )*#{surname})\z/ record.errors[attribute] << ([:message] || 'is not a name') end end |