OpenForm
AITools

validateArtifact

Last updated on

Validate an OpenForm artifact against the schema and logic rules

Validates an OpenForm artifact (form, document, bundle, or checklist) against the OpenForm schema and optionally checks logic expressions.

Input modes

The validateArtifact tool accepts three input modes via a discriminated union on the source field:

ModeFieldsResolution
source: "artifact"artifact, baseUrl?Direct — artifact JSON provided inline
source: "url"urlFetches artifact JSON from a URL
source: "registry"registryUrl, artifactNameFetches registry.json, finds item, fetches artifact

All modes share these fields:

ParameterTypeRequiredDescription
options.schemabooleanNoValidate schema structure (default: true)
options.logicbooleanNoValidate logic expressions (default: true)

Response

FieldTypeDescription
validbooleanWhether the artifact passed validation
detectedKindstringDetected artifact kind: form, document, bundle, or checklist
issuesarrayList of validation issues, each with message and optional path
errorstringError message if validation could not be performed

Direct usage

From artifact JSON

import { executeValidateArtifact } from "@open-form/ai-tools"

const result = await executeValidateArtifact({
  source: "artifact",
  artifact: {
    kind: "form",
    name: "my-form",
    fields: {
      name: { type: "text", label: "Name" },
    },
  },
})
// { valid: true, detectedKind: "form" }

The executeValidateArtifact function accepts an optional second config parameter for custom fetch settings. See the configuration reference.

From URL

const result = await executeValidateArtifact({
  source: "url",
  url: "https://public.open-form.dev/pet-addendum/pet-addendum.json",
})

From registry

const result = await executeValidateArtifact({
  source: "registry",
  registryUrl: "https://public.open-form.dev",
  artifactName: "pet-addendum",
})

Example responses

Valid artifact

{
  "valid": true,
  "detectedKind": "form"
}

Invalid artifact

{
  "valid": false,
  "detectedKind": "form",
  "issues": [
    {
      "message": "Required property 'name' is missing",
      "path": ["name"]
    }
  ]
}

Disabling checks

Pass options to disable schema or logic validation independently:

await executeValidateArtifact({
  source: "artifact",
  artifact: { kind: "form", name: "my-form", /* ... */ },
  options: { schema: true, logic: false },
})

On this page