Class: IscCodeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- IscCodeValidator
- Defined in:
- app/validators/isc_code_validator.rb
Instance Method Summary collapse
- #attribute_message(isc_lookup, object) ⇒ Object
-
#build_error_message(object, isc_lookup) ⇒ Object
—————————————————————–# Removing the custom message below for performance reasons # —————————————————————–#.
- #cms_table_message(isc_lookup) ⇒ Object
- #validate_each(object, attribute, value) ⇒ Object
Instance Method Details
#attribute_message(isc_lookup, object) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/validators/isc_code_validator.rb', line 32 def (isc_lookup, object) if isc_lookup.isc_lookup_value == IscCode.inactivation_code = "x0100 => #{object.x0100} " else = "a0200 => #{object.a0200}, a0310a => #{object.a0310a}, a0310b => #{object.a0310b}, a0310c => #{object.a0310c}, a0310d => #{object.a0310d}, a0310f => #{object.a0310f}." end end |
#build_error_message(object, isc_lookup) ⇒ Object
—————————————————————–# Removing the custom message below for performance reasons # —————————————————————–#
14 15 16 17 18 19 20 |
# File 'app/validators/isc_code_validator.rb', line 14 def (object, isc_lookup) = "The ISC value in this file (#{isc_lookup.isc_provided_value}), " += (isc_lookup) += "Please ensure these values are correct: " += (isc_lookup, object) end |
#cms_table_message(isc_lookup) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/validators/isc_code_validator.rb', line 23 def (isc_lookup) if isc_lookup.isc_lookup_value.nil? = "does not match any value provided in the CMS lookup table. " else = "does not match the value provided in the CMS lookup table (#{isc_lookup.isc_lookup_value}). " end end |
#validate_each(object, attribute, value) ⇒ Object
4 5 6 7 |
# File 'app/validators/isc_code_validator.rb', line 4 def validate_each(object, attribute, value) isc_lookup = Services::IscCodeLookup.new(object) object.errors[attribute] << "The ISC Code provided: #{isc_lookup.isc_provided_value} is incorrect for this assessment." unless isc_lookup.valid_isc_value? end |