Sha256: 88f1653d94e854e98e69e4e33339b13ea49f4fb6ed9dd64146a17a7e5cd46140

Contents?: true

Size: 313 Bytes

Versions: 3

Compression:

Stored size: 313 Bytes

Contents

module HashieModel
  class AssociatedValidator < ActiveModel::EachValidator
    def validate_each(record, attribute, value)
      return if (value.is_a?(Array) ? value : [value]).collect{ |r| r.nil? || r.valid? }.all?
      record.errors.add(attribute, :invalid, options.merge(:value => value))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hashie-model-1.1.0 lib/hashie_model/associated_validator.rb
hashie-model-1.0.1 lib/hashie_model/associated_validator.rb
hashie-model-1.0.0.alpha lib/hashie_model/associated_validator.rb