Class: ActiveModel::Validations::EmplidValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::EmplidValidator
- Defined in:
- lib/osu_validators/osu_emplid_validator.rb
Overview
Validate’s that a user’s emplid is an 8-9 digit string
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/osu_validators/osu_emplid_validator.rb', line 5 def validate_each(record, attribute, value) return if value.blank? && [:allow_blank] return if !!value && [:allow_nil] return if ::OSU::Emplid.valid?(value) = [:message] || "needs to be an 8-9 digit string" record.errors.add( attribute, :emplid, message: , value: value ) end |