Class: DailyAffirmation::Validators::EqualityValidator

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

Overview

This affirmation ensures an attribute is equal to the :value option given.

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



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

def error_message
  @error_message ||= i18n_error_message(
    :equality, :default => "#{attribute} is not '#{opts[:value]}'"
  )
end

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/daily_affirmation/validators/equality_validator.rb', line 10

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