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.


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

def initialize(item)
  @item = item
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item


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

def item
  @item
end

Instance Method Details

#callObject


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

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