import { AnySchema, InferObject, InferSchema, SchemaDefinition, SchemaType } from "./core/types.mjs"; import { ArraySchema, InstanceOfSchema, LiteralSchema, NullSchemaType, OptionalSchema, UnionSchema } from "./core/base.mjs"; import { AnySchemaType, NeverSchemaType, UnknownSchemaType } from "./schemas/any.mjs"; import { BigIntSchemaType } from "./schemas/bigint.mjs"; import { BooleanSchemaType } from "./schemas/boolean.mjs"; import { DefaultSchema } from "./schemas/default.mjs"; import { ObjectSchemaType } from "./schemas/object.mjs"; import { DiscriminatedUnionSchema } from "./schemas/discriminated-union.mjs"; import { IntersectionSchema } from "./schemas/intersection.mjs"; import { LazySchema } from "./schemas/lazy.mjs"; import { MapSchema } from "./schemas/map.mjs"; import { NumberSchemaType } from "./schemas/number.mjs"; import { RecordSchema } from "./schemas/record.mjs"; import { RefineCheck, RefineSchema } from "./schemas/refine.mjs"; import { SetSchema } from "./schemas/set.mjs"; import { StringSchemaType } from "./schemas/string.mjs"; import { PipeSchema, TransformSchema } from "./schemas/transform.mjs"; import { TupleSchema } from "./schemas/tuple.mjs"; import { UndefinedSchemaType, VoidSchemaType } from "./schemas/undefined.mjs"; import { getJsonSchema, toStandard } from "./to-standard.mjs"; //#region src/h.d.ts /** * The `h` builder: factory functions for constructing validation schemas. * * @example * const user = h.object({ id: h.uuid(), name: h.string().minLength(1) }); */ declare const h: { /** Create a string schema. */ string: () => StringSchemaType; /** Create a number schema. */ number: () => NumberSchemaType; /** Create a boolean schema. */ boolean: () => BooleanSchemaType; /** Create a bigint schema. */ bigint: () => BigIntSchemaType; /** Create a null schema. */ null: () => NullSchemaType; /** Alias of {@link h.null}. */ nullable: () => NullSchemaType; /** Create an undefined schema. */ undefined: () => UndefinedSchemaType; /** Create a void schema. */ void: () => VoidSchemaType; /** Create an `any` schema. */ any: () => AnySchemaType; /** Create an `unknown` schema. */ unknown: () => UnknownSchemaType; /** Create a `never` schema (always fails). */ never: () => NeverSchemaType; /** * Literal value schema. * @param value Literal value to match. */ literal: (value: T) => LiteralSchema; /** * Object schema. * @param schemaDef Field definitions. */ object: (schemaDef?: S) => ObjectSchemaType>; /** * Record schema (object with dynamic keys). * @param keyOrValue Key schema (when 2 args) or value schema (when 1 arg). * @param maybeValue Value schema if a key schema was provided. */ record: { (value: V): RecordSchema>; (key: K, value: V): RecordSchema & (string | number), SchemaType>; }; /** * Tuple schema (fixed-length, positional). * @param schemas Item schemas. */ tuple: (...schemas: S) => TupleSchema; }>; /** * Map schema. * @param key Key schema. * @param value Value schema. */ map: (key: K, value: V) => MapSchema, SchemaType>; /** * Set schema. * @param value Value schema. */ set: (value: V) => SetSchema>; /** * Intersection schema (combines all schemas). * @param schemas Schemas to intersect. */ intersection: (...schemas: S) => IntersectionSchema>; /** * Discriminated union: faster than `options` for tagged unions. * @param discriminator Field name acting as the tag. * @param options Object schemas, each with the discriminator as a literal. */ discriminatedUnion: (discriminator: D, options: ObjectSchemaType[]) => DiscriminatedUnionSchema; /** * Lazy schema for recursive types. * @param getter Function returning the inner schema. */ lazy: (getter: () => S) => LazySchema>; /** * Default value when the input is undefined or null. * @param schema Inner schema. * @param defaultValue Value or factory. */ default: (schema: S, defaultValue: InferSchema | (() => InferSchema)) => DefaultSchema>; /** * Apply a transformation to the validated value. * @param schema Inner schema. * @param fn Transform function. */ transform: (schema: S, fn: (value: InferSchema) => Out) => TransformSchema, Out>; /** * Apply a custom validation predicate. * @param schema Inner schema. * @param check Predicate returning true / false / message / issues. * @param message Default message when predicate returns false. */ refine: (schema: S, check: RefineCheck>, message?: string) => RefineSchema>; /** * Pipe one schema's output into another schema's input. * @param a First schema. * @param b Second schema receiving `a`'s output. */ pipe: (a: A, b: B) => PipeSchema, InferSchema>; /** * Array schema. * @param schema Item schema. */ array: (schema: S) => ArraySchema[]>; /** * Enum schema from a list of literal values. * @param values Allowed literals. */ enum: (values: Values) => UnionSchema; /** * Optional schema (allows undefined). * @param schema Inner schema. */ optional: (schema: S) => OptionalSchema | undefined>; /** * Union schema (succeeds if any branch succeeds). * @param schemas Branch schemas. */ options: (...schemas: S) => UnionSchema>; /** * Alias of {@link h.options}. */ union: (...schemas: S) => UnionSchema>; /** * Restrict to instances of a constructor. * @param constructor Class constructor. */ instanceOf: any>(constructor: C) => InstanceOfSchema>; /** Date string schema. */ date: () => StringSchemaType; /** UUID string schema. */ uuid: () => StringSchemaType; /** Regex string schema. */ regex: (regex: RegExp) => StringSchemaType; /** Email string schema. */ email: () => StringSchemaType; /** Phone string schema. */ phone: () => StringSchemaType; /** Domain string schema. */ domain: (requireHttpOrHttps?: boolean) => StringSchemaType; /** * Coerce-then-validate factories. Equivalent to `h.X().coerce()`. */ coerce: { /** Coerce input to string. */ string: () => StringSchemaType; /** Coerce input to number. */ number: () => NumberSchemaType; /** Coerce input to boolean. */ boolean: () => BooleanSchemaType; /** Coerce input to bigint. */ bigint: () => BigIntSchemaType; }; /** Re-export of {@link toStandard}. */ toStandard: typeof toStandard; /** * Get JSON Schema from a validation schema. * @param schema Schema to convert. * @param options Conversion options. */ getJsonSchema: typeof getJsonSchema; }; //#endregion export { h }; //# sourceMappingURL=h.d.mts.map