Class: DataValidator::AcceptanceValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- DataValidator::AcceptanceValidator
- Defined in:
- lib/validations/acceptance.rb
Instance Attribute Summary
Attributes inherited from BaseValidator
#errors, #name, #options, #value
Instance Method Summary collapse
-
#initialize(name, value, options, errors) ⇒ AcceptanceValidator
constructor
A new instance of AcceptanceValidator.
- #validate ⇒ Object
Methods inherited from BaseValidator
Constructor Details
#initialize(name, value, options, errors) ⇒ AcceptanceValidator
Returns a new instance of AcceptanceValidator.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/validations/acceptance.rb', line 5 def initialize(name, value, , errors) raise ArgumentError, 'Options must define' unless case when Hash = else = {} end super(name, value, .reverse_merge(:allow_nil => true, :accept => "1"), errors) end |
Instance Method Details
#validate ⇒ Object
16 17 18 19 20 |
# File 'lib/validations/acceptance.rb', line 16 def validate unless value == [:accept] add_error :accepted end end |