//#region src/core/schema/standard.d.ts
/**
* The Standard Schema v1 interface, vendored as types only.
*
* Mirrors the specification at https://standardschema.dev so validators from
* zod, valibot, arktype, and any other conforming library can be passed to
* `flag.custom()` / `arg.custom()` without adding a runtime dependency.
*
* @module
*/
/** A schema that conforms to the Standard Schema v1 specification. */
interface StandardSchemaV1 {
/** The Standard Schema properties, namespaced under a well-known key. */
readonly '~standard': StandardSchemaV1.Props ;
}
/** Types copied from the Standard Schema v1 specification. */
declare namespace StandardSchemaV1 {
/** The properties exposed under a validator's `~standard` key. */
interface Props {
/** The version number of the specification. */
readonly version: 1;
/** The vendor name of the schema library. */
readonly vendor: string;
/** Validate an unknown value, returning its output or the issues found. */
readonly validate: (value: unknown, options?: Options | undefined) => Result | Promise>;
/** Inferred input and output types, present only at the type level. */
readonly types?: Types | undefined;
}
/** Optional parameters passed to a validator. */
interface Options {
/** Explicit support for vendor-specific validation parameters. */
readonly libraryOptions?: Record | undefined;
}
/** The result of validating a value: either its output or a list of issues. */
type Result = SuccessResult | FailureResult;
/** A successful validation carrying the parsed output value. */
interface SuccessResult {
/** The validated (and possibly transformed) value. */
readonly value: Output;
/** Absent on success. */
readonly issues?: undefined;
}
/** A failed validation carrying validation issues. */
interface FailureResult {
/** The issues that caused validation to fail. */
readonly issues: ReadonlyArray;
}
/** A single validation issue. */
interface Issue {
/** The human-readable error message. */
readonly message: string;
/** The path to the offending value, when the validator reports one. */
readonly path?: ReadonlyArray | undefined;
}
/** One segment of an issue path. */
interface PathSegment {
/** The key of this path segment. */
readonly key: PropertyKey;
}
/** The type-level input and output carried by a validator. */
interface Types {
/** The input type accepted by the validator. */
readonly input: Input;
/** The output type produced by the validator. */
readonly output: Output;
}
/** Infer the input type of a Standard Schema validator. */
type InferInput = NonNullable['input'];
/** Infer the output type of a Standard Schema validator. */
type InferOutput = NonNullable['output'];
}
/** Backward-compatible flat alias for {@link StandardSchemaV1.Props}. */
type StandardSchemaV1Props = StandardSchemaV1.Props ;
/** Flat alias for {@link StandardSchemaV1.Options}. */
type StandardSchemaV1Options = StandardSchemaV1.Options;
/** Flat alias for {@link StandardSchemaV1.Result}. */
type StandardSchemaV1Result = StandardSchemaV1.Result;
/** Flat alias for {@link StandardSchemaV1.SuccessResult}. */
type StandardSchemaV1SuccessResult = StandardSchemaV1.SuccessResult;
/** Flat alias for {@link StandardSchemaV1.FailureResult}. */
type StandardSchemaV1FailureResult = StandardSchemaV1.FailureResult;
/** Flat alias for {@link StandardSchemaV1.Issue}. */
type StandardSchemaV1Issue = StandardSchemaV1.Issue;
/** Flat alias for {@link StandardSchemaV1.PathSegment}. */
type StandardSchemaV1PathSegment = StandardSchemaV1.PathSegment;
/** Backward-compatible flat alias for {@link StandardSchemaV1.Types}. */
type StandardSchemaV1Types = StandardSchemaV1.Types ;
/** Flat alias for {@link StandardSchemaV1.InferInput}. */
type InferStandardInput = StandardSchemaV1.InferInput;
/** Flat alias for {@link StandardSchemaV1.InferOutput}. */
type InferStandardOutput = StandardSchemaV1.InferOutput;
/**
* Detect a Standard Schema validator without assuming validators are plain
* objects. Some conforming libraries expose callable schema values.
*
* @internal
*/
declare function isStandardSchemaV1(value: unknown): value is StandardSchemaV1;
//#endregion
export { InferStandardInput, InferStandardOutput, StandardSchemaV1, StandardSchemaV1FailureResult, StandardSchemaV1Issue, StandardSchemaV1Options, StandardSchemaV1PathSegment, StandardSchemaV1Props, StandardSchemaV1Result, StandardSchemaV1SuccessResult, StandardSchemaV1Types, isStandardSchemaV1 };