Skip to content

validateDraft

function validateDraft(draft): ValidationResult;

Defined in: validation.ts:371

Validate every flag in a draft. Errors are prefixed with the flag key.

Parameter Type
draft Draft

ValidationResult

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);
}