Class: SecurityIdentifiers::Validations::CusipValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- SecurityIdentifiers::Validations::CusipValidator
- Defined in:
- lib/security_identifiers/validations/cusip_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/security_identifiers/validations/cusip_validator.rb', line 4 def validate_each(record, attribute, value) cusip = CUSIP.new(value) record.errors[attribute] << 'does not have a valid check digit' unless cusip.valid? rescue SecurityIdentifiers::InvalidFormat record.errors[attribute] << 'is not in the correct format' end |