import { Validator } from "./validators"; export interface FieldOptions extends Record { nullable?: boolean; optional?: boolean; } export declare type FieldValues = F extends Field ? { rawInternal: Opts["nullable"] extends true ? VRI | null : VRI; internal: Opts["nullable"] extends true ? VI | null : VI; rawExternal: Opts["optional"] extends true ? VRE | undefined : VRE; external: Opts["optional"] extends true ? VE | undefined : VE; } : unknown; export declare type Lazy = { [P in keyof T]: () => T[P]; }; export declare type NonLazy = T extends Lazy ? R : unknown; export declare abstract class Field { readonly options: Opts; validators: Validator[]; readonly nullable: boolean | undefined; readonly optional: boolean | undefined; constructor(options: Opts); abstract toInternalValue(value: VRI): () => VI; abstract toExternalValue(value: VRE): VE; toInternal(value: VRI | null): () => Opts["nullable"] extends true ? VI | null : VI; toExternal(value: VRE | undefined): Opts["optional"] extends true ? VE | undefined : VE; /** * Entry method for validations. * * Skip main validations if the value is and is allowed to be `null`. * @param value * @returns Whether the validations are fully executed. */ validate(value: T): value is Exclude; validateNull(value: unknown): value is null | undefined; runValidators(value: unknown): void; } export declare abstract class SimpleField extends Field { toInternalValue(value: V): () => V; toExternalValue(value: V): V; } export declare class StringField extends SimpleField { readonly minLength: number | undefined; readonly maxLength: number | undefined; readonly choices: Choices[] | undefined; constructor(options: Opts & { minLength?: number; maxLength?: number; choices?: Choices[]; }); } export declare class NumberField extends SimpleField { readonly maxValue: number | undefined; readonly minValue: number | undefined; readonly choices: Choices[] | undefined; constructor(options: Opts & { maxValue?: number; minValue?: number; choices?: Choices[]; }); } export declare class BooleanField extends SimpleField { constructor(options: Opts); } export declare class DateField extends Field { readonly minValue: Date | undefined; readonly maxValue: Date | undefined; constructor(options: Opts & { minValue?: Date; maxValue?: Date; }); toInternalValue(value: string): () => Date; toExternalValue(value: Date): string; } export declare class ListField extends Field["rawInternal"][], FieldValues["internal"][], FieldValues["rawExternal"][], FieldValues["external"][]> { readonly field: Child; constructor(options: Opts & { field: Child; }); toInternalValue(value: FieldValues["rawInternal"][]): () => FieldValues["internal"][]; toExternalValue(value: FieldValues["rawExternal"][]): FieldValues["external"][]; } //# sourceMappingURL=fields.d.ts.map