Class: DailyAffirmation::Validators::NumericalityValidator

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

Overview

This affirmation ensures an attribute is a Number and if the :greater_than or :less_then option is given, that the attribute is greater than or less than the value provided.

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



18
19
20
21
22
# File 'lib/daily_affirmation/validators/numericality_validator.rb', line 18

def error_message
  @error_message ||= i18n_error_message(
    :numericality, :default => default_error_message
  )
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/daily_affirmation/validators/numericality_validator.rb', line 14

def valid?
  @valid ||= value ? numeric? && greater_than? && less_than? : true
end