# validate_artifact

Validate a Paradoc artifact definition against the schema and logic rules

Canonical URL: https://docs.paradoc.dev/ai-tools/validate-artifact/

Checks an artifact definition (form, document, bundle, or checklist) against the Paradoc schema and its logic rules, including the template expressions in its text and DOCX layers. Inline layers are always checked; file-backed layers are read relative to the source's base URL (with an [artifact source](/ai-tools#sources), set `base_url`). Use it after an agent writes or edits an artifact. To check a value a user gives, use [`validate_input`](/ai-tools/validate-input).

## Input

Takes a [source](/ai-tools#sources) plus:

| Field            | Type      | Required | Description                                              |
| ---------------- | --------- | -------- | -------------------------------------------------------- |
| `options.schema` | `boolean` | No       | Run schema validation. Default `true`.                   |
| `options.logic`  | `boolean` | No       | Validate logic and template expressions. Default `true`. |

## Output

| Field           | Type                            | Description                                                                           |
| --------------- | ------------------------------- | ------------------------------------------------------------------------------------- |
| `valid`         | `boolean`                       | Whether the artifact passed                                                           |
| `artifact_kind` | `string`                        | `form`, `document`, `bundle`, or `checklist`, when detected                           |
| `issues`        | `{ message, path? }[]`          | Validation issues, when invalid                                                       |
| `warnings`      | `{ message, path? }[]`          | Findings that do not make the artifact invalid                                        |
| `error`         | [`ToolError`](/ai-tools#errors) | Set when validation could not run, for example because the source could not be loaded |

## Direct usage

```typescript
import { executeValidateArtifact } from "@paradoc/ai-tools"

const result = await executeValidateArtifact({
  source: "artifact",
  artifact: {
    kind: "form",
    name: "contact",
    version: "1.0.0",
    title: "Contact",
    fields: {
      name: { type: "text", label: "Name", required: true },
    },
  },
})
```

From a registry, with logic checks off:

```typescript
const result = await executeValidateArtifact({
  source: "registry",
  registry_url: "https://public.paradoc.dev",
  artifact_name: "pet-addendum",
  options: { logic: false },
})
```

## Example responses

### Valid artifact

```json
{
  "valid": true,
  "artifact_kind": "form"
}
```

### Invalid artifact

```json
{
  "valid": false,
  "artifact_kind": "form",
  "issues": [
    { "message": "Invalid input", "path": ["fields", "name"] }
  ]
}
```
