Class: Textus::Doctor::Check::SchemaViolations

Inherits:
Textus::Doctor::Check show all
Defined in:
lib/textus/doctor/check/schema_violations.rb

Instance Method Summary collapse

Methods inherited from Textus::Doctor::Check

#initialize, name_key

Constructor Details

This class inherits a constructor from Textus::Doctor::Check

Instance Method Details

#callObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/textus/doctor/check/schema_violations.rb', line 5

def call
  res = store.validate_all
  res["violations"].map do |v|
    fix = v["expected"] &&
          "field '#{v["field"]}' should be written by '#{v["expected"]}' (last writer: #{v["last_writer"]})"
    {
      "code" => v["code"],
      "level" => "error",
      "subject" => v["key"],
      "message" => v["message"] || "#{v["code"]} on #{v["key"]}",
      "fix" => fix,
    }.compact
  end
end