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
8 9 10 |
# File 'lib/app/validators/is_curacao_phone_validator.rb', line 8 def "is geen geldig Curaçao telefoon nummer." end |
#help_message ⇒ Object
12 13 14 |
# File 'lib/app/validators/is_curacao_phone_validator.rb', line 12 def "Telefoonnummer moet 7 cijfers zijn, bijvoorbeeld 6781256." end |
#validate_each(record, attribute, value) ⇒ Object
16 17 18 19 20 |
# File 'lib/app/validators/is_curacao_phone_validator.rb', line 16 def validate_each(record, attribute, value) unless value =~ /[4-8][0-9]{6}/ record.errors[attribute] << ([:message] || ) end end |