Class: JsonldValidate::Validator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Validator

Returns a new instance of Validator.



7
8
9
10
# File 'lib/jsonld_validate/validator.rb', line 7

def initialize(content)
  @content = content
  @errors = []
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/jsonld_validate/validator.rb', line 5

def content
  @content
end

#errorsObject

Returns the value of attribute errors.



5
6
7
# File 'lib/jsonld_validate/validator.rb', line 5

def errors
  @errors
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jsonld_validate/validator.rb', line 12

def valid?
  return false if content.nil?
  return true if content.empty?

  build_expanded_doc
  build_doc
  return false unless errors.empty?

  find_unknown_fields(content, doc, [])

  errors.empty?
end