Class: Ankh::Validations::HumanValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/ankh/validations/human_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HumanValidator

Returns a new instance of HumanValidator.



4
5
6
# File 'lib/ankh/validations/human_validator.rb', line 4

def initialize(options = {})
  @options ||= options
end

Instance Method Details

#validate(record) ⇒ Object



8
9
10
11
12
13
# File 'lib/ankh/validations/human_validator.rb', line 8

def validate(record)
  if has_valid_answer?(record)
    record.errors.add(:human_answer, @options[:message] || "is not valid")
  end
  record.human_answer = ""
end