Paradoc
AITools

validateArtifact

Last updated on

Validate an Paradoc artifact against the schema and logic rules

Validates an Paradoc artifact (form, document, bundle, or checklist) against the Paradoc 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 "@paradoc/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.paradoc.dev/pet-addendum/pet-addendum.json",
})

From registry

const result = await executeValidateArtifact({
  source: "registry",
  registryUrl: "https://public.paradoc.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 },
})

Logic checking

With options.logic on, every visible / required / def / rule expression is checked by the typed @paradoc/expr checker. Each issue names the offending expression and its path, catching unknown references (fields are addressed as fields.<id>, with no .value), unknown functions, type mismatches, and gates that don't return a boolean. The checker shares its type system with runtime evaluation, so a passing artifact won't behave differently when filled.

On this page