import { file, FileValidator } from './file-validator'; import { objectWithContext } from './object-with-context'; import { withConditionals } from './conditional'; import type { ConditionalAPI } from './conditional'; import type { ObjectWithContextValidator } from './object-with-context'; import type { ValidationInstance, Validator } from '@stacksjs/ts-validation'; export type { FileLike } from './file-validator'; export type { ConditionalAPI, ConditionalRecord, ValidatorWithConditionals } from './conditional'; export type { InferObjectShape, InferValidatorValue, ObjectWithContextValidator, ValidatorShape } from './object-with-context'; /** * `Object.assign({}, v, { file })` would defeat the ts-validation * proxy's late-binding. Wrapping with `new Proxy` keeps every existing * `schema.()` call going through the upstream proxy while only * intercepting the slots we own (`file`, `object`, and the conditional * mixin on primitive factories). */ export declare const schema: SchemaWithFile; export declare interface InferredEnumValidator extends Validator { readonly name: 'enum' getAllowedValues: () => readonly TValue[] custom: (fn: (value: TValue) => boolean, message: string) => InferredEnumValidator } export declare interface InferredArrayValidator extends Validator { readonly name: 'array' min: (length: number) => InferredArrayValidator max: (length: number) => InferredArrayValidator length: (length: number) => InferredArrayValidator each: (validator: Validator) => InferredArrayValidator unique: () => InferredArrayValidator } declare type WithConditionals> = TValidator & ConditionalAPI; declare type ConditionalValidationInstance = { // eslint-disable-next-line pickier/no-unused-vars [TKey in keyof ValidationInstance]: ValidationInstance[TKey] extends (...args: infer TArgs) => infer TValidator ? TValidator extends Validator // eslint-disable-next-line pickier/no-unused-vars ? (...args: TArgs) => WithConditionals : ValidationInstance[TKey] : ValidationInstance[TKey] } /** * Extended `ValidationInstance` that adds `schema.file()` on top of the * ts-validation surface (stacksjs/stacks#1856). Upstream ts-validation * has `string()`, `number()`, `enum()`, etc. but no `file()` validator; * we layer one here without forking ts-validation so the rest of the * surface keeps working unchanged. * * The runtime value is the ts-validation proxy with `file` patched in, * `object` swapped for the context-aware variant (stacksjs/stacks#1890), * and every primitive factory wrapped to attach `.when()` / `.sometimes()` * to the returned validator. */ export type SchemaWithFile = Omit & { file: () => FileValidator array: () => WithConditionals> enum: (values: TValues) => WithConditionals> object: typeof objectWithContext } export { file, FileValidator } from './file-validator'; export { applyConditionals, shouldApplyConditional, withConditionals } from './conditional'; export { objectWithContext } from './object-with-context';