class DailyAffirmation::Validators::LengthValidator
This affirmation ensures an attribute’s size is within the provided :range option.
@option opts [Range] :range the range the size of the attribute’s value
must fit in.
Public Instance Methods
error_message()
click to toggle source
# File lib/daily_affirmation/validators/length_validator.rb, line 15 def error_message @error_message ||= i18n_error_message( :length, :default => "#{attribute} is the wrong length (allowed #{opts[:range]})" ) end
valid?()
click to toggle source
# File lib/daily_affirmation/validators/length_validator.rb, line 11 def valid? @valid ||= opts[:range].include?(value.size) end