import { JsonSchemaResult, JsonSchemaTarget } from "../standard-schema/json-schema.mjs"; import { BaseValidator } from "./base-validator.mjs"; //#region ../@warlock.js/seal/src/validators/literal-validator.d.ts /** * Literal validator class * * Accepts a fixed tuple of primitive literal values (string, number, boolean). * The TypeScript type narrows to the union of those literals — `v.literal("a", "b")` * infers as `"a" | "b"`, not `string`. Use for discriminator fields, enum-like * unions of constants, and any case where `oneOf([...])` would lose literal types. * * @example * v.literal("items") // type: "items" * v.literal("draft", "published") // type: "draft" | "published" * v.literal(1, 2, 3) // type: 1 | 2 | 3 * v.literal(true) // type: true */ declare class LiteralValidator extends BaseValidator { values: T; constructor(values: T, errorMessage?: string); /** * Check if value is one of the configured literals */ matchesType(value: any): boolean; /** * Clone the validator, preserving the literal `values` set. * * The base `clone()` only copies `BaseValidator` fields, so without this * override a cloned literal loses its public `values` array — which breaks * any consumer that reads it (e.g. `discriminatedUnion` branch routing). */ clone(): this; /** * @inheritdoc * * Single literal → `{ const: }`. Multiple → `{ enum: [...] }`. * * @example * ```ts * v.literal("items").toJsonSchema() * // → { const: "items" } * * v.literal("draft", "published").toJsonSchema() * // → { enum: ["draft", "published"] } * ``` */ toJsonSchema(target?: JsonSchemaTarget): JsonSchemaResult; } //#endregion export { LiteralValidator }; //# sourceMappingURL=literal-validator.d.mts.map