Class: Hyrax::Arkivo::SchemaValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/hyrax/arkivo/schema_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ SchemaValidator

Returns a new instance of SchemaValidator.



44
45
46
# File 'lib/hyrax/arkivo/schema_validator.rb', line 44

def initialize(item)
  @item = item
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



42
43
44
# File 'lib/hyrax/arkivo/schema_validator.rb', line 42

def item
  @item
end

Instance Method Details

#callObject



48
49
50
51
52
# File 'lib/hyrax/arkivo/schema_validator.rb', line 48

def call
  JSON::Validator.validate!(Hyrax::Arkivo::ITEM_SCHEMA, item, version: :draft3)
rescue JSON::Schema::ValidationError => exception
  raise Hyrax::Arkivo::InvalidItem, exception.message
end