Class: ActiveModel::Validations::AcceptanceValidator
- Inherits:
-
EachValidator
- Object
- ActiveModel::Validator
- EachValidator
- ActiveModel::Validations::AcceptanceValidator
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/validations/acceptance.rb
Overview
:nodoc:
Defined Under Namespace
Classes: LazilyDefineAttributes
Instance Attribute Summary
Attributes inherited from EachValidator
Attributes inherited from ActiveModel::Validator
Instance Method Summary collapse
-
#initialize(options) ⇒ AcceptanceValidator
constructor
A new instance of AcceptanceValidator.
- #validate_each(record, attribute, value) ⇒ Object
Methods inherited from EachValidator
Methods inherited from ActiveModel::Validator
Constructor Details
#initialize(options) ⇒ AcceptanceValidator
Returns a new instance of AcceptanceValidator.
6 7 8 9 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/validations/acceptance.rb', line 6 def initialize() super({ allow_nil: true, accept: ["1", true] }.merge!()) setup!([:class]) end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
11 12 13 14 15 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/validations/acceptance.rb', line 11 def validate_each(record, attribute, value) unless acceptable_option?(value) record.errors.add(attribute, :accepted, **.except(:accept, :allow_nil)) end end |