Class: Citizenship::Rails::Validators::PhoneValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/citizenship/rails/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



21
22
23
24
25
# File 'lib/citizenship/rails/validators.rb', line 21

def validate_each(record, attribute, value)
  Citizenship.valid_phone!(value, options) if value.present?
rescue Citizenship::PhoneError => e
  record.errors[attribute] << (options[:message] || e.message)
end