AITools
validateArtifactLast updated on
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:
| Mode | Fields | Resolution |
|---|---|---|
source: "artifact" | artifact, baseUrl? | Direct — artifact JSON provided inline |
source: "url" | url | Fetches artifact JSON from a URL |
source: "registry" | registryUrl, artifactName | Fetches registry.json, finds item, fetches artifact |
All modes share these fields:
| Parameter | Type | Required | Description |
|---|---|---|---|
options.schema | boolean | No | Validate schema structure (default: true) |
options.logic | boolean | No | Validate logic expressions (default: true) |
Response
| Field | Type | Description |
|---|---|---|
valid | boolean | Whether the artifact passed validation |
detectedKind | string | Detected artifact kind: form, document, bundle, or checklist |
issues | array | List of validation issues, each with message and optional path |
error | string | Error 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 },
})