Class: Citizenship::Rails::Validators::NifValidator

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



5
6
7
8
9
# File 'lib/citizenship/rails/validators.rb', line 5

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