Class: CnsBrazil::CnsValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- CnsBrazil::CnsValidator
- Defined in:
- lib/cns_brazil/cns_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/cns_brazil/cns_validator.rb', line 6 def validate_each(record, attribute, value) return true if [:allow_blank] && value.blank? cns = CnsBrazil::Cns.new(value: value) record.errors.add(attribute, ([:message] || 'is not an cns')) unless cns.valid? end |