Class: Canvas::ValidCustomTypesCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/canvas/checks/valid_custom_types_check.rb

Overview

:documented: This check will validate the JSON objects that represent the custom types that are defined in the /types directory.

Instance Attribute Summary

Attributes inherited from Check

#offenses

Instance Method Summary collapse

Methods inherited from Check

#failed?, #initialize

Constructor Details

This class inherits a constructor from Canvas::Check

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/canvas/checks/valid_custom_types_check.rb', line 8

def run
  custom_type_files.each do |filename|
    schema = extract_json(filename)
    validator = Validator::CustomType.new(schema: schema)

    next if validator.validate

    validator.errors.each do |message|
      @offenses << Offense.new(
        message: "Invalid Custom Type: #{filename} - \n#{message}"
      )
    end
  end
end