Class: Validatable::ValidatesAcceptanceOf
- Inherits:
-
ValidationBase
- Object
- ValidationBase
- Validatable::ValidatesAcceptanceOf
- Defined in:
- lib/validatable/validations/validates_acceptance_of.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from ValidationBase
#after_validate, #allow_blank, #allow_nil, #attribute, #if, #klass
Instance Method Summary collapse
Methods inherited from ValidationBase
Constructor Details
This class inherits a constructor from Validatable::ValidationBase
Instance Method Details
permalink #message(instance) ⇒ Object
[View source]
10 11 12 |
# File 'lib/validatable/validations/validates_acceptance_of.rb', line 10 def (instance) super || "must be accepted" end |
permalink #valid?(instance) ⇒ Boolean
3 4 5 6 7 8 |
# File 'lib/validatable/validations/validates_acceptance_of.rb', line 3 def valid?(instance) value = instance.send(self.attribute) return true if allow_nil && value.nil? return true if allow_blank && (!value or (value.respond_to?(:empty?) and value.empty?)) %w(1 true t).include?(value) end |