Class: Einvoice::Neweb::Validator::BuyerNameValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/einvoice/neweb/validator/invoice_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
9
10
# File 'lib/einvoice/neweb/validator/invoice_validator.rb', line 5

def validate_each(record, attribute, value)
  if record.buyer_id.to_s == "0000000000" &&
     value.present? && (value.ascii_only? ? value.size > 4 : value.size > 2)
    record.errors.add attribute, options[:message] || :invalid
  end
end