Class: DailyAffirmation::Validators::InclusionValidator

Inherits:
DailyAffirmation::Validator show all
Defined in:
lib/daily_affirmation/validators/inclusion_validator.rb

Overview

This affirmation ensures an attribute is in the provided :list option.

Instance Method Summary collapse

Methods inherited from DailyAffirmation::Validator

#affirm, #initialize

Constructor Details

This class inherits a constructor from DailyAffirmation::Validator

Instance Method Details

#error_messageObject



13
14
15
16
17
18
# File 'lib/daily_affirmation/validators/inclusion_validator.rb', line 13

def error_message
  @error_message ||= i18n_error_message(
    :inclusion,
    :default => "#{attribute} is not included in #{opts[:list]}"
  )
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/daily_affirmation/validators/inclusion_validator.rb', line 9

def valid?
  @valid ||= opts[:list].include?(value)
end