Sha256: 7c352418710e434f9edcebb1d10215ce6f0b8dbf4d3c01e87e8ca92c8e060357

Contents?: true

Size: 664 Bytes

Versions: 6

Compression:

Stored size: 664 Bytes

Contents

# frozen_string_literal: true

require "json_schema"

module Datacite
  # Validates the request data is valid
  class Validator
    def self.validate!(data)
      # Schema from https://github.com/datacite/schema/blob/master/source/json/kernel-4.3/datacite_4.3_schema.json
      # with changes:
      #  1. Remove invalid formats https://github.com/datacite/schema/issues/96
      #  2. Remove required fields https://github.com/datacite/schema/issues/97
      #  3. Added "additionalProperties": false

      schema_data = JSON.parse(File.read("#{__dir__}/schema.json"))
      schema = JsonSchema.parse!(schema_data)
      schema.validate!(data)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datacite-0.4.0 lib/datacite/validator.rb
datacite-0.3.0 lib/datacite/validator.rb
datacite-0.2.3 lib/datacite/validator.rb
datacite-0.2.2 lib/datacite/validator.rb
datacite-0.2.1 lib/datacite/validator.rb
datacite-0.2.0 lib/datacite/validator.rb