validate(markup) is the only required step for a .gui file — the schema gate that answers “is this broken?”, returning structured errors with codes and tree paths.

/validate

gatethe only required step

The one hard check in a file’s life. It answers “is this broken?” — not “is this good?”. Illegal or unparseable markup can’t be saved as a real .gui, so validation is the gate every write passes through.

It returns a structured result: valid or not, the detected version, and a list of errors and warnings each carrying a code, a message, and a path into the tree.

Signature

validate(guiXml: string): ValidationResult

interface ValidationResult {
  valid: boolean
  version: string | null
  errors: ValidationError[]
  warnings: ValidationError[]
}
interface ValidationError {
  code: string
  message: string
  path: string        // e.g. "gui > stack[0] > text[2]"
}

Use cases

  • The required gate before writing or packing a .gui.
  • Editor diagnostics — surface schema errors inline as the user types.
  • CI — fail a build on malformed markup.

Validate markup

import { validate } from '@dotgui/kit/validate'

const result = validate('<gui platform="web-desktop"><frame/></gui>')
if (!result.valid) {
  for (const e of result.errors) console.error(e)
}

Gate a write — refuse to save broken markup

import { validate } from '@dotgui/kit/validate'
import { pack } from '@dotgui/kit/package'

function save(xml: string) {
  const { valid, errors } = validate(xml)
  if (!valid) throw new Error('invalid .gui: ' + JSON.stringify(errors))
  return pack({ xml, assets: {} })
}