Sha256: dbd1a9af55ed78be3897d79bcf04d1ff3fe07e68efd2b98ef325159ed0c869eb

Contents?: true

Size: 535 Bytes

Versions: 22

Compression:

Stored size: 535 Bytes

Contents

module CouchRest
  module Model
    module Validations
      class CastedModelValidator < ActiveModel::EachValidator
        
        def validate_each(document, attribute, value)
          values = value.is_a?(Array) ? value : [value]
          return if values.collect {|doc| doc.nil? || doc.valid? }.all?
          error_options = { :value => value }
          error_options[:message] = options[:message] if options[:message]
          document.errors.add(attribute, :invalid, error_options)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
couchrest_model-2.2.0.beta2 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.2.0.beta1 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.1.0.rc1 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.1.0.beta2 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.1.0.beta1 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.0.4 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.0.3 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.0.1 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.0.0 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.0.0.beta2 lib/couchrest/model/validations/casted_model.rb
couchrest_model-2.0.0.beta lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.2.0.beta lib/couchrest/model/validations/casted_model.rb
openlogic-couchrest_model-1.0.0 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.1.2 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.1.1 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.1.0 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.1.0.rc1 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.1.0.beta5 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.1.0.beta4 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.1.0.beta3 lib/couchrest/model/validations/casted_model.rb