Class: ActiveModel::Validations::CuitValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::CuitValidator
- Defined in:
- lib/active_model/validations/cuit_validator.rb
Overview
Here start the implementation of CUIT/CUIL validator
Constant Summary collapse
- CHECKS =
[ :separator, :dni_compatible, :gender_compatible ].freeze
Instance Method Summary collapse
-
#check_validity! ⇒ Object
Hook that checks the options validity for this validator.
- #validate_each(record, attr_name, value) ⇒ Object
Instance Method Details
#check_validity! ⇒ Object
Hook that checks the options validity for this validator
15 16 17 18 |
# File 'lib/active_model/validations/cuit_validator.rb', line 15 def check_validity! = .keys - CHECKS raise ArgumentError, "#{invalid_options} are invalid CUIT/CUIL options. You can use only these: #{CHECKS.join(', ')}" unless .empty? end |
#validate_each(record, attr_name, value) ⇒ Object
20 21 22 23 |
# File 'lib/active_model/validations/cuit_validator.rb', line 20 def validate_each(record, attr_name, value) return if detect_any_failure_in :length, :digits, :dni_compatibility, :gender_compatibility, :v_digit, data: [ record, attr_name, value ] end |