Sha256: 96856f6cf9517fb3212638791032f56c30d01b2abee0822a7f7d3dfa66e66619

Contents?: true

Size: 447 Bytes

Versions: 6

Compression:

Stored size: 447 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?
          document.errors.add(attribute, :invalid, :default => options[:message], :value => value)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
couchrest_model-1.0.0 lib/couchrest/model/validations/casted_model.rb
couchrest_model-radiant-1.0.0 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.0.0.beta8 lib/couchrest/model/validations/casted_model.rb
couchrest_model_thought-1.0.0.beta9 lib/couchrest/model/validations/casted_model.rb
couchrest_model_thought-1.0.0.beta8 lib/couchrest/model/validations/casted_model.rb
couchrest_model-1.0.0.beta7 lib/couchrest/model/validations/casted_model.rb