Class: JanValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/jan_validator.rb,
lib/jan_validator/version.rb

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
# File 'lib/jan_validator.rb', line 5

def validate_each(record, attribute, value)
  record.errors.add(attribute, "is invalid length") unless Jan::Validator.validate_size(value)
  record.errors.add(attribute, "is invalid check-digit") unless Jan::Validator.validate_check_digit(value)
end