Class: LicenseValidator::Validations::StateMa
- Defined in:
- lib/license_validator/validations/state_ma.rb
Instance Attribute Summary
Attributes inherited from Base
#driver, #errors, #infos, #warnings
Instance Method Summary collapse
Methods inherited from Base
human_attribute_name, #initialize, lookup_ancestors, #read_attribute_for_validation, #validation_results
Constructor Details
This class inherits a constructor from LicenseValidator::Validations::Base
Instance Method Details
#validate ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/license_validator/validations/state_ma.rb', line 7 def validate super lic_num = driver.license_num return if lic_num.match?(/\A[b-z]\d{8}\z/i) return if lic_num.match?(/\A[a-z]{2}\d{7}\z/i) && !lic_num.match?(/\Afr\d{7}\z/i) errors.add( :license_num, 'License number requires 1 alphabetic (B-Z), 8 numeric or 2 alphabetic (excluding FR), 7 numeric for MA.' ) end |