Sha256: 333de9c144e93a89156b49b3bd14ae1aad00cdf75d6bc0aa4d2c677cea4296f0
Contents?: true
Size: 1.5 KB
Versions: 25
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true require 'json-schema' module Hyrax module Arkivo ITEM_SCHEMA = { type: 'object', properties: { token: { type: 'string', required: true }, metadata: { type: 'object', required: true, properties: { title: { type: 'string', required: true }, license: { type: 'string', required: true }, resourceType: { type: 'string' }, description: { type: 'string' }, publisher: { type: 'string' }, dateCreated: { type: 'string' }, basedNear: { type: 'string' }, identifier: { type: 'string' }, url: { type: 'string' }, language: { type: 'string' } } }, file: { type: 'object', required: true, properties: { base64: { type: 'string', required: true }, md5: { type: 'string', required: true }, filename: { type: 'string', required: true }, contentType: { type: 'string', required: true } } } } }.freeze class InvalidItem < RuntimeError end class SchemaValidator attr_reader :item def initialize(item) @item = item end def call JSON::Validator.validate!(Hyrax::Arkivo::ITEM_SCHEMA, item, version: :draft3) rescue JSON::Schema::ValidationError => exception raise Hyrax::Arkivo::InvalidItem, exception.message end end end end
Version data entries
25 entries across 25 versions & 1 rubygems