class RenderEditorjs::Validator

Attributes

data[R]
errors[R]
schema[R]

Public Class Methods

new(data, schema) click to toggle source
# File lib/render_editorjs/validator.rb, line 7
def initialize(data, schema)
  @data = data
  @schema = schema

  @errors = []
end

Public Instance Methods

valid?() click to toggle source
# File lib/render_editorjs/validator.rb, line 14
def valid?
  validate!
rescue JSON::Schema::ValidationError => e
  @errors << e.message

  false
end
validate!() click to toggle source
# File lib/render_editorjs/validator.rb, line 22
def validate!
  JSON::Validator.validate!(schema, data)
end