Class: VanillaValidator::Rules::Falsy

Inherits:
BaseRule
  • Object
show all
Defined in:
lib/vanilla_validator/rules/falsy.rb

Instance Attribute Summary

Attributes inherited from BaseRule

#attribute, #parameters, #value

Instance Method Summary collapse

Methods inherited from BaseRule

#initialize

Constructor Details

This class inherits a constructor from VanillaValidator::Rules::BaseRule

Instance Method Details

#failure_messageObject



9
10
11
# File 'lib/vanilla_validator/rules/falsy.rb', line 9

def failure_message
  I18n.t('falsy', attribute: attribute)
end

#valid?Boolean

Returns:



4
5
6
7
# File 'lib/vanilla_validator/rules/falsy.rb', line 4

def valid?
  acceptable = ['no', 'off', '0', 0, false, 'false']
  required? && acceptable.include?(value)
end