Class: IsCuracaoPhoneValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- IsCuracaoPhoneValidator
- Defined in:
- lib/app/validators/is_curacao_phone_validator.rb
Overview
usage:
in your model, add:
validates :email, :presence => true, :is_email_address => true;
taken from lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true (It’s probably a fake regex but hey, it looks legit.)
Instance Method Summary collapse
Instance Method Details
#error_message ⇒ Object
9 10 11 |
# File 'lib/app/validators/is_curacao_phone_validator.rb', line 9 def "is geen geldig Curaçao telefoon nummer." end |
#help_message ⇒ Object
13 14 15 |
# File 'lib/app/validators/is_curacao_phone_validator.rb', line 13 def "Telefoonnummer moet 7 cijfers zijn, bijvoorbeeld 6781256." end |
#validate_each(record, attribute, value) ⇒ Object
17 18 19 20 21 |
# File 'lib/app/validators/is_curacao_phone_validator.rb', line 17 def validate_each(record, attribute, value) unless value =~ /[4-8][0-9]{6}/ record.errors[attribute] << ([:message] || ) end end |