Class: LicenseValidator::Validations::StateOr
- Defined in:
- lib/license_validator/validations/state_or.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 21 |
# File 'lib/license_validator/validations/state_or.rb', line 7 def validate super if driver.dob.blank? errors.add(:dob, 'D.O.B. is required for OR.') end license = driver.license_num return if license.match?(/\A[a-z]\d{6}\z/i) return if license.match?(/\A\d{7}\z/i) errors.add(:license_num, 'License number requires 7 numeric or 1 alpha, 6 numeric for OR.') end |