Class: Strum::JsonSchema::Validate

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
lib/strum/json_schema/validate.rb

Instance Method Summary collapse

Methods included from Service

#errors, #execute, #failure, #hook, included, #initialize, #method_missing, #on, #respond_to_missing?, #success, #valid?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Strum::Service

Instance Method Details

#auditObject



17
18
19
# File 'lib/strum/json_schema/validate.rb', line 17

def audit
  add_error(:schema, :not_found) if !args[:schema].is_a?(Hash)
end

#callObject



11
12
13
14
15
# File 'lib/strum/json_schema/validate.rb', line 11

def call
  array_errors = JSON::Validator.fully_validate(args[:schema], input, errors_as_objects: true)
  array_errors.each { |error| add_error(*parse_json_schema_error(error)) }
  output(input)
end