# File lib/dm-validations/validators/uniqueness_validator.rb, line 28
      def valid?(target)
        value = target.validation_property_value(field_name)
        return true if optional?(value)

        opts = {
          :fields    => target.model.key(target.repository.name),
          field_name => value,
        }

        Array(@options[:scope]).each { |subject|
          unless target.respond_to?(subject)
            raise(ArgumentError,"Could not find property to scope by: #{subject}. Note that :unique does not currently support arbitrarily named groups, for that you should use :unique_index with an explicit validates_uniqueness_of.")
          end

          opts[subject] = target.__send__(subject)
        }

        resource = DataMapper.repository(target.repository.name) do
          target.model.first(opts)
        end

        return true if resource.nil?
        target.saved? && resource.key == target.key
      end