class CouchRest::Validation::AbsentFieldValidator

@author Guy van den Berg

Public Instance Methods

call(target) click to toggle source
# File lib/couchrest/validation/validators/absent_field_validator.rb, line 37
def call(target)
  value = target.send(field_name)
  return true if (value.nil? || (value.respond_to?(:empty?) && value.empty?))

  error_message = @options[:message] || ValidationErrors.default_error_message(:absent, field_name)
  add_error(target, error_message, field_name)

  return false
end

Public Class Methods

new(field_name, options={}) click to toggle source
# File lib/couchrest/validation/validators/absent_field_validator.rb, line 32
def initialize(field_name, options={})
  super
  @field_name, @options = field_name, options
end