Sha256: 3a506286ef5023634db5c5f75c70d3f8c19aaa8c3cfb3d92d3fea5d3ebfdc60f

Contents?: true

Size: 590 Bytes

Versions: 15

Compression:

Stored size: 590 Bytes

Contents

# frozen_string_literal: true

module CqmValidators
  module Schema
    class Validator
      include BaseValidator

      def initialize(name, schema_file)
        @name = name
        @schema_file = schema_file
        @xsd = Nokogiri::XML::Schema(File.new(@schema_file))
      end

      # Validate the document against the configured schema
      def validate(document, data = {})
        @xsd.errors.clear
        doc = get_document(document)
        @xsd.validate(doc).map do |error|
          build_error(error.message, '/', data[:file_name])
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cqm-validators-4.0.5 lib/schema_validator.rb
cqm-validators-4.0.4 lib/schema_validator.rb
cqm-validators-4.0.3 lib/schema_validator.rb
cqm-validators-4.0.2 lib/schema_validator.rb
cqm-validators-4.0.1 lib/schema_validator.rb
cqm-validators-3.1.3 lib/schema_validator.rb
cqm-validators-4.0.0 lib/schema_validator.rb
cqm-validators-3.1.2 lib/schema_validator.rb
cqm-validators-3.1.1 lib/schema_validator.rb
cqm-validators-2.0.2 lib/schema_validator.rb
cqm-validators-3.0.1 lib/schema_validator.rb
cqm-validators-3.0.0 lib/schema_validator.rb
cqm-validators-2.0.1 lib/schema_validator.rb
cqm-validators-2.0.0 lib/schema_validator.rb
cqm-validators-1.0.1.0 lib/schema_validator.rb