Class: LicenseValidator::Validations::StateNv
- Defined in:
- lib/license_validator/validations/state_nv.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 |
# File 'lib/license_validator/validations/state_nv.rb', line 7 def validate super dob_year = driver.dob.present? ? driver.dob.strftime('%y') : nil regex = Regexp.new("\\A\\d{10}(#{dob_year})?\\z", 'i') # 12 numeric (last 2 are year of birth) or 10 numeric return if driver.license_num.match?(regex) errors.add(:license_num, 'License number requires 12 numeric (last 2 are year of birth) or 10 numeric for NV.') end |