Sha256: e63d3d75c1869359ef226af47b476a4b3eeed14401fbd0f7b467a3278593f8f4

Contents?: true

Size: 570 Bytes

Versions: 8

Compression:

Stored size: 570 Bytes

Contents

require 'active_model'
require 'golden_fleece/validations/validator_context'

module GoldenFleece
  module Validations
    module ActiveModel
      class FleeceSchemaConformanceValidator < ::ActiveModel::EachValidator
        def validate_each(record, attribute, persisted_json)
          context = record.class.fleece_context
          errors = ValidatorContext.new(record, attribute, persisted_json, context.schemas[attribute], '/').validate

          errors.each { |e| record.errors.add attribute, e }
          errors.empty?
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
golden_fleece-1.0.1 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb
golden_fleece-1.0.0 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb
golden_fleece-0.1.5 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb
golden_fleece-0.1.4 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb
golden_fleece-0.1.3 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb
golden_fleece-0.1.2 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb
golden_fleece-0.1.1 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb
golden_fleece-0.1.0 lib/golden_fleece/validations/active_model/fleece_schema_conformance_validator.rb