validateDraft
function validateDraft(draft): ValidationResult;Defined in: validation.ts:371
Validate every flag in a draft. Errors are prefixed with the flag key.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
draft |
Draft |
Returns
Section titled “Returns”Example
Section titled “Example”import { validateDraft } from "@xtandard/flags";
const result = validateDraft({ projectKey: "default", environmentKey: "production", flags: { "dark-mode": { key: "dark-mode", type: "boolean", enabled: true, defaultVariant: "off", variants: { on: { value: true }, off: { value: false } }, fallthrough: { variant: "off" }, }, },});if (!result.valid) { for (const e of result.errors) console.error(e.path, e.message);}