Class: NipValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/common_numbers_rails/nip_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



6
7
8
9
# File 'lib/common_numbers_rails/nip_validator.rb', line 6

def validate_each(record, attribute, value)
  @message = options[:message] || "invalid format"
  record.errors[attribute] << @message unless CommonNumbers::Polish::Nip.new(value).valid?
end