First validation workflow

Execute one failing validation intentionally and interpret every returned error line.

Goal

Run one end-to-end validation, force a failure, and read the error list correctly.

Prerequisites

  • Plugin installed and enabled.
  • Skript installed.
  • Access to plugins/Schema-Validator/.

Step 1: Create a schema

{
  "type": "object",
  "required": ["id", "level"],
  "additionalProperties": false,
  "properties": {
    "id": {"type": "string"},
    "level": {"type": "integer", "minimum": 1}
  }
}

Save as plugins/Schema-Validator/schemas/player.schema.json.

Step 2: Create invalid data

id: "player-01"
level: 0
extra: true

Save as plugins/Schema-Validator/data/player.yml.

Step 3: Run the Skript validation command

validate yaml "plugins/Schema-Validator/data/player.yml" using schema "plugins/Schema-Validator/schemas/player.schema.json"
set {_errors::*} to last schema validation errors
loop {_errors::*}:
    broadcast "%loop-value%"

Step 4: Read the failure output

Expected failures in this scenario:

  • minimum failure for level.
  • additionalProperties failure for extra.

If _errors::* is empty, your data unexpectedly passed and the test payload is not failing the current schema.

Next

Was this page helpful?

No personal data collected — Privacy Policy