Class: DailyAffirmation::Validators::CustomValidator

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

Overview

This affirmation accepts a :proc option and evaluates it’s results.

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/custom_validator.rb', line 14

def error_message
  @error_message ||= i18n_error_message(
    :custom, :default => "#{attribute} is invalid"
  )
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  @valid ||= opts[:proc].call(object)
end