class DailyAffirmation::Validators::FormatValidator

This affirmation ensures an attribute matches the provided :regex option.

@option opts [Regex] :regex the patten the attributes value must match.

Public Instance Methods

error_message() click to toggle source
# File lib/daily_affirmation/validators/format_validator.rb, line 13
def error_message
  @error_message ||= i18n_error_message(
    :format, :default => "#{attribute} is invalid"
  )
end
valid?() click to toggle source
# File lib/daily_affirmation/validators/format_validator.rb, line 9
def valid?
  @valid ||= !!opts[:regex].match(value)
end