Module: ActiveModel::Validations::HelperMethods
- Defined in:
- lib/siret_validator.rb
Instance Method Summary collapse
-
#validates_siret_of(*attr_names) ⇒ Object
Validates whether the value of the specified attribute is a valid SIRET number.
Instance Method Details
#validates_siret_of(*attr_names) ⇒ Object
Validates whether the value of the specified attribute is a valid SIRET number.
A SIRET number is valid if:
-
It is made of exactly 14 digits (otherwise a
:wrong_siret_formaterror is added). -
Its checksum is valid (otherwise an
:invaliderror is added).class TaxesFilling include ActiveModel::Validations attr_accessor :company_siret validates_siret_of :company_siret end
Configuration options:
- :message - A custom error message.
There is also a list of default options supported by every validator:
:if, :unless, :on, :allow_nil, :allow_blank, and :strict.
See ActiveModel::Validations::ClassMethods#validates for more information.
78 79 80 |
# File 'lib/siret_validator.rb', line 78 def validates_siret_of(*attr_names) validates_with SiretValidator, _merge_attributes(attr_names) end |