Class: RfcFormatValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- RfcFormatValidator
- Defined in:
- lib/rfc_format_validator.rb
Instance Method Summary collapse
Instance Method Details
#rfc_regexp ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rfc_format_validator.rb', line 9 def rfc_regexp if [:force_homoclave] /\A[A-ZÑ&]{3,4}[0-9]{2}[0-1][0-9][0-3][0-9][A-Z0-9]{3}\z/i else /\A[A-ZÑ&]{3,4}[0-9]{2}[0-1][0-9][0-3][0-9]([A-Z0-9]{3})?\z/i end end |
#validate_each(object, attribute, value) ⇒ Object
3 4 5 6 7 |
# File 'lib/rfc_format_validator.rb', line 3 def validate_each(object, attribute, value) unless value =~ rfc_regexp object.errors[attribute] << ([:message] || "no es un RFC válido") end end |