Class: DailyAffirmation::Validators::FormatValidator
- Inherits:
-
DailyAffirmation::Validator
- Object
- DailyAffirmation::Validator
- DailyAffirmation::Validators::FormatValidator
- Defined in:
- lib/daily_affirmation/validators/format_validator.rb
Overview
This affirmation ensures an attribute matches the provided :regex option.
Instance Method Summary collapse
Methods inherited from DailyAffirmation::Validator
Constructor Details
This class inherits a constructor from DailyAffirmation::Validator
Instance Method Details
#error_message ⇒ Object
13 14 15 16 17 |
# File 'lib/daily_affirmation/validators/format_validator.rb', line 13 def @error_message ||= ( :format, :default => "#{attribute} is invalid" ) end |
#valid? ⇒ Boolean
9 10 11 |
# File 'lib/daily_affirmation/validators/format_validator.rb', line 9 def valid? @valid ||= !!opts[:regex].match(value) end |