Class: SecretAnswerValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/secret_answer_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



2
3
4
5
6
# File 'app/validators/secret_answer_validator.rb', line 2

def validate(record)
  if record.secret_answer.strip.downcase != record.recorded_answer.strip.downcase
    record.errors.add(:secret_answer, I18n.t('presenter.save_and_return.validation.answer_not_matched', attempts: record.attempts_remaining))
  end
end