Class: ActiveModel::Validations::PhoneValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/bootstripe-rails/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



16
17
18
# File 'lib/bootstripe-rails/validators.rb', line 16

def validate_each(record, attribute, value)
  record.errors[attribute] << 'is not properly formatted' unless /1?\W*([2-9][0-8][0-9])\W*([2-9][0-9]{2})\W*([0-9]{4})(\se?x?t?(\d*))?/.match(value)
end