Method: Validatable::Macros#validates_format_of
- Defined in:
- lib/validatable/macros.rb
#validates_format_of(*args) ⇒ Object
call-seq: validates_format_of(*args)
Validates whether the value of the specified attribute is of the correct form by matching it against the regular expression provided.
class Person
include Validatable
validates_format_of :first_name, :with => /[ A-Za-z]/
end
A regular expression must be provided or else an exception will be raised.
Configuration options:
* after_validate - A block that executes following the run of a validation
* message - The message to add to the errors collection when the validation fails
* times - The number of times the validation applies
* level - The level at which the validation should occur
* if - A block that when executed must return true of the validation will not occur
* with - The regular expression used to validate the format
* group - The group that this validation belongs to. A validation can belong to multiple groups
48 49 50 |
# File 'lib/validatable/macros.rb', line 48 def validates_format_of(*args) add_validations(args, ValidatesFormatOf) end |