Class: DailyAffirmation::Validators::LengthValidator
- Inherits:
-
DailyAffirmation::Validator
- Object
- DailyAffirmation::Validator
- DailyAffirmation::Validators::LengthValidator
- Defined in:
- lib/daily_affirmation/validators/length_validator.rb
Overview
This affirmation ensures an attribute’s size is within the provided :range 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
15 16 17 18 19 20 |
# File 'lib/daily_affirmation/validators/length_validator.rb', line 15 def @error_message ||= ( :length, :default => "#{attribute} is the wrong length (allowed #{opts[:range]})" ) end |
#valid? ⇒ Boolean
11 12 13 |
# File 'lib/daily_affirmation/validators/length_validator.rb', line 11 def valid? @valid ||= opts[:range].include?(value.size) end |