Class: UcNumberValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- UcNumberValidator
- Defined in:
- lib/ar_validator.rb
Overview
Provides AR validations for UC Student IDs.
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
3 4 5 6 7 |
# File 'lib/ar_validator.rb', line 3 def validate_each(record, attribute, value) unless value.is_a?(String) && value.valid_uc_number? record.errors[attribute] << [:message] || 'is not a valid uc number' end end |