/** * Standard Schema V1 integration * * Defines the public Standard Schema V1 surface (https://standardschema.dev) * and exposes the `attachStandard()` helper used by every UMT validator * factory to advertise itself as a Standard Schema V1 implementation. The * `~standard` property added by `attachStandard()` lets external tools * (Zod-, Valibot-, ArkType-style ecosystems) consume UMT validators without * adapters. * * Biome's `noNamespace` lint rule forbids TypeScript namespaces, so the spec * is mirrored with flat interface/type names that remain structurally * compatible with the official `StandardSchemaV1` interface published by * `@standard-schema/spec`. */ /** The Standard Schema V1 interface. */ export interface StandardSchemaV1 { readonly "~standard": StandardSchemaV1Properties; } /** The Standard Schema V1 properties interface. */ export interface StandardSchemaV1Properties { /** The version number of the standard. */ readonly version: 1; /** The vendor name of the schema library. */ readonly vendor: string; /** Validates unknown input values. */ readonly validate: (value: unknown) => StandardSchemaV1Result | Promise>; /** Inferred types associated with the schema. */ readonly types?: StandardSchemaV1Types | undefined; } /** The result type produced by `Props.validate`. */ export type StandardSchemaV1Result = StandardSchemaV1SuccessResult | StandardSchemaV1FailureResult; /** The result interface when validation succeeds. */ export interface StandardSchemaV1SuccessResult { readonly value: Output; readonly issues?: undefined; } /** The result interface when validation fails. */ export interface StandardSchemaV1FailureResult { readonly issues: readonly StandardSchemaV1Issue[]; } /** The issue interface returned on failure. */ export interface StandardSchemaV1Issue { readonly message: string; readonly path?: readonly (PropertyKey | StandardSchemaV1PathSegment)[] | undefined; } /** The path segment interface for nested issues. */ export interface StandardSchemaV1PathSegment { readonly key: PropertyKey; } /** The Standard Schema V1 types interface. */ export interface StandardSchemaV1Types { /** The input type of the schema. */ readonly input: Input; /** The output type of the schema. */ readonly output: Output; } /** Infers the input type of a Standard Schema V1 implementation. */ export type StandardSchemaV1InferInput> = NonNullable["input"]; /** Infers the output type of a Standard Schema V1 implementation. */ export type StandardSchemaV1InferOutput> = NonNullable["output"]; /** * Vendor identifier used by all UMT validators when advertising Standard * Schema V1 compatibility. External tools may key off this value to attach * UMT-specific behavior. */ export declare const STANDARD_SCHEMA_VENDOR = "umt"; /** Minimal shape of UMT validator results consumed by `attachStandard`. */ export interface UmtValidatorResult { validate: boolean; message: string; type: unknown; } /** * Attaches a Standard Schema V1 `~standard` property to a UMT validator * function in place. The validator's existing call signature, attached * helpers (such as `shape` on `object()` or `implement` on `func()`), * and return type are preserved untouched; only the `~standard` property is * added. * * Validation is delegated to the wrapped validator. On success the input * value is returned through the Standard Schema `value` field; on failure a * single issue carrying the validator's message is emitted. UMT validators * never transform their input, so `Input` and `Output` default to the same * type. * * @template Input - The input type advertised through `~standard.types` * @template Output - The output type advertised through `~standard.types` * @template F - The validator function being augmented * @param {F} validator - The validator function to augment * @returns {F & StandardSchemaV1} The same function with `~standard` attached */ export declare const attachStandard: UmtValidatorResult = (...arguments_: any[]) => UmtValidatorResult>(validator: F) => F & StandardSchemaV1;