Quickstart

Run one successful and one failing validation end to end.

Goal

Validate one YAML payload against one JSON schema and inspect error output in Skript.

Step 1: Pick known-good sample files

Use the bundled examples copied by the plugin:

  • Schema: plugins/Schema-Validator/examples/schemas/simple-block-schema.json
  • Data: plugins/Schema-Validator/examples/simple-block-example.yml

[!IMPORTANT] The validate yaml/json effect uses Path.of(...). Paths are resolved from the server process working directory. Use explicit paths relative to server root (for example plugins/Schema-Validator/...) to avoid ambiguity.

Step 2: Create a minimal validation command

command /schemaquickstart:
    trigger:
        validate yaml "plugins/Schema-Validator/examples/simple-block-example.yml" using schema "plugins/Schema-Validator/examples/schemas/simple-block-schema.json"

        set {_errors::*} to last schema validation errors

        if size of {_errors::*} is 0:
            send "Validation passed" to player
        else:
            send "Validation failed:" to player
            loop {_errors::*}:
                send "- %loop-value%" to player

Step 3: Confirm success case

Run /schemaquickstart with original sample files.

Expected result:

  • _errors::* is empty
  • message Validation passed

Step 4: Force one controlled failure

Edit simple-block-example.yml and break one value, for example:

hardness:
  base: "not-a-number"

Run /schemaquickstart again.

Expected result:

  • _errors::* is not empty
  • at least one compact error with the failing path ($.hardness.base)

Step 5: Read compact error format

last schema validation errors returns compact strings generated by ValidationError.toCompactString().

Format:

[nodePath] expectedType: actualType - description

Common quickstart pitfalls

  • Passing a path that does not exist from server root.
  • Validating with a schema file that has unsupported keywords while strict-mode: true.
  • Assuming _errors::* persists forever. It always reflects the latest validation result only.

Continue

  1. Tune startup and strictness in Configuration.
  2. Inspect keyword support in Schema keywords.
  3. For plugin-to-plugin integration, use Java API.

Was this page helpful?

No personal data collected — Privacy Policy