Class: Validatable::ValidatesFormatOf
- Inherits:
-
ValidationBase
- Object
- ValidationBase
- Validatable::ValidatesFormatOf
- Defined in:
- lib/validates_format_of.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#regex ⇒ Object
Returns the value of attribute regex.
Attributes inherited from ValidationBase
Instance Method Summary collapse
-
#initialize(attribute, regex, message) ⇒ ValidatesFormatOf
constructor
A new instance of ValidatesFormatOf.
- #valid?(instance) ⇒ Boolean
Constructor Details
#initialize(attribute, regex, message) ⇒ ValidatesFormatOf
Returns a new instance of ValidatesFormatOf.
4 5 6 7 |
# File 'lib/validates_format_of.rb', line 4 def initialize(attribute, regex, ) self.regex = regex super attribute, end |
Instance Attribute Details
#regex ⇒ Object
Returns the value of attribute regex.
3 4 5 |
# File 'lib/validates_format_of.rb', line 3 def regex @regex end |
Instance Method Details
#valid?(instance) ⇒ Boolean
9 10 11 |
# File 'lib/validates_format_of.rb', line 9 def valid?(instance) instance.send(self.attribute) =~ self.regex && true end |