class PersonWithValidator::LikeValidator

Public Class Methods

new(options) click to toggle source
Calls superclass method ActiveModel::Validator::new
# File activemodel/test/models/person_with_validator.rb, line 13
def initialize(options)
  @with = options[:with]
  super
end

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File activemodel/test/models/person_with_validator.rb, line 18
def validate_each(record, attribute, value)
  unless value[@with]
    record.errors.add attribute, "does not appear to be like #{@with}"
  end
end