Class: Datacite::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/datacite/validator.rb

Overview

Validates the request data is valid

Class Method Summary collapse

Class Method Details

.validate!(data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/datacite/validator.rb', line 8

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