Class: VanillaValidator::Rules::RequiredIf
- Defined in:
- lib/vanilla_validator/rules/required_if.rb
Instance Attribute Summary
Attributes inherited from BaseRule
#attribute, #parameters, #value
Instance Method Summary collapse
Methods inherited from BaseRule
Constructor Details
This class inherits a constructor from VanillaValidator::Rules::BaseRule
Instance Method Details
#failure_message ⇒ Object
10 11 12 |
# File 'lib/vanilla_validator/rules/required_if.rb', line 10 def I18n.t("required_if", attribute: attribute, other: parameters[0].to_i, value: value) end |
#valid? ⇒ Boolean
4 5 6 7 8 |
# File 'lib/vanilla_validator/rules/required_if.rb', line 4 def valid? other_rule = VanillaValidator::Rules::OtherRule.(VanillaValidator.raw_input, parameters) other_rule.klass.valid? && required? end |