Class: Validatable::ValidatesFormatOf
- Inherits:
-
ValidationBase
- Object
- ValidationBase
- Validatable::ValidatesFormatOf
- Defined in:
- lib/validatable/validations/validates_format_of.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#with ⇒ Object
Returns the value of attribute with.
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 Attribute Details
#with ⇒ Object
Returns the value of attribute with.
3 4 5 |
# File 'lib/validatable/validations/validates_format_of.rb', line 3 def with @with end |
Instance Method Details
#message(instance) ⇒ Object
12 13 14 |
# File 'lib/validatable/validations/validates_format_of.rb', line 12 def (instance) super || "is invalid" end |
#valid?(instance) ⇒ Boolean
5 6 7 8 9 10 |
# File 'lib/validatable/validations/validates_format_of.rb', line 5 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?)) not (value.to_s =~ self.with).nil? end |