class Devise::Orm::DataMapper::UniquenessValidator

Public Instance Methods

validate_each(target, attribute, value) click to toggle source
# File lib/devise/orm/data_mapper/validations/active_model.rb, line 23
def validate_each(target, attribute, value)
  resource = ::DataMapper.repository(target.repository.name) { target.model.first(attribute => value) }
  if resource.nil? || (target.saved? && resource.key == target.key)
    return true
  else
    target.errors.add(attribute, :taken)
    return false
  end
end