import { Buffer } from 'buffer'; import { NamedTypeDefinition, ObjectType, Type } from './reflection-type'; export declare class MakeError extends Error { readonly errors: ValidationError[]; readonly name = "MakeError"; constructor(errors: ValidationError[]); } export interface ErrorGroup { groupMessage: string; errors: ValidationError[]; } export interface ValidationError { path: Path; error: string | ErrorGroup; } type Path = ReadonlyArray; export declare function validationErrorPrinter(error: ValidationError, indentation?: number): string; export declare class Make { static ok(value: V): Make; static error(errors: ValidationError[]): Make; readonly errors: ValidationError[]; private readonly value; private constructor(); isError(): boolean; isSuccess(): boolean; success(handler?: (e: this) => V): V; group(groupMessage: string): Make; errorPath(path: string): Make; map(fn: (value: V) => R): Make; } export interface MakeOptions { /** * if 'true' merge types between successive '.make' calls for the object * RECOMMEND not to set this unless you have thought things through */ mergeTypes?: boolean; unknownField?: 'drop' | 'fail'; /** * If enabled, "number" ans "integer" schemas will accept strings and try to parse them. */ parseNumericStrings?: boolean; /** * If enabled, "boolean" schemas will accept strings and try to parse them. */ parseBooleanStrings?: boolean; /** * If enabled, "array" schema will convert any non-array value to an array with a single element. * Useful for supporting arrays in query parameters * (if query parameter is not repeated, it will not be an array on server side). */ allowConvertForArrayType?: boolean; /** If true convert property names from network to ts format while parsing objects */ convertFromNetwork?: boolean; } export type Maker = (value: Shape, opts?: MakeOptions) => Make; export declare function registerFormat(format: string, maker: Maker): void; export declare function makeString(format?: string, pattern?: string, minLength?: number, maxLength?: number): Maker; export declare function makeNumber(min?: number, max?: number): Maker; export declare function makeInteger(min?: number, max?: number): Maker; declare function checkAny(value: any, opts?: MakeOptions): Make; export declare function makeAny(): typeof checkAny; declare function checkVoid(value: any): Make; export declare function makeVoid(): typeof checkVoid; export declare function makeEnum(...args: T[]): (value: T) => Make; export declare function makeOptional(maker: any): { optional: any; }; export declare function makeBoolean(): Maker; export declare function makeArray(maker: any, minSize?: number, maxSize?: number): Maker; export declare function makeOneOf(...options: any[]): (value: any, opts?: MakeOptions) => any; export declare function makeAllOf(...all: Maker[]): (value: any, opts?: MakeOptions) => Make; export declare function makeObject

| { optional: Maker; }; }>(props: P, additionalProp?: Maker | undefined, comparisorOrder?: string[], type?: ObjectType): (value: any, opts?: MakeOptions) => Make; interface FormDataArguments { value: any; options: string | undefined | { [key: string]: string; }; } export type Binary = File | Buffer | FormBinary; export declare class FormBinary { readonly binary: Binary; readonly options?: FormDataArguments['options']; constructor(binary: Binary, options?: FormDataArguments['options']); } export declare class File { readonly path: string; readonly size: number; readonly name?: string | undefined; private brand; constructor(path: string, size: number, name?: string | undefined); } declare function checkBinary(value: any): Make; export declare function makeBinary(): typeof checkBinary; export declare function makeNullable(maker: any): (value: any, opts?: MakeOptions) => any; export declare function fromReflection(type: Type): Maker; export declare function createMaker(fun: () => any): (value: Shape, opts?: MakeOptions) => Make; export declare function createMakerWith(constructor: new (v: Shape, opts?: MakeOptions) => Type): Maker; /** * Merge multiple mappings into one set of mappings * * Throw error if there are duplicate koys * @deprecated */ export declare function mergeMappings(...mappings: readonly { [key: string]: Maker; }[]): { [key: string]: Maker; }; export declare function extractDiscriminatorKeys(discriminatorField: string, typeObjectRef: Type): string[]; /** @deprecated */ export declare function extractDiscriminatorValueMap(discriminatorField: string, typeObject: NamedTypeDefinition): { [key: string]: Maker; }; /** * Make oneOf with the discriminator support * * Will use given mapping to find correct maker. If optional importedTypes are provided, will extract * extra mapping keys from them. * * @deprecated * * @param discriminatorField Field to use as discriminator * @param mapping Mappings that we should use to determine target makers * @param importedTypes Optional types where we should extract enum values for makers */ export declare function makeOneOfWithDiscriminator(discriminatorField: string, mapping: { [key: string]: Maker; }, importedTypes?: readonly any[]): (value: any, opts?: MakeOptions) => Make; export {};