UNPKG

variable-value-validator

Version:

Minimal schema validation for TypeScript and JavaScript.

51 lines (50 loc) 3.85 kB
import type { StandardSchemaV1 } from "@standard-schema/spec"; import type { Schema, SchemaOptions, UnknownSchema, StringSchema, BooleanSchema, NumberSchema, UndefinedSchema, NullSchema, NullishSchema, FunctionSchema, ObjectConstructor, InstanceSchema, ObjectShape, ObjectShapeToOutput, ObjectSchema, ArraySchema, UnionSchema, RecordSchema, SetSchema, MapSchema } from "./types"; export declare function unknown<Optional extends boolean>(options?: SchemaOptions<unknown, Optional>): Omit<UnknownSchema, "options"> & { options: NoInfer<typeof options>; }; export declare function string<Optional extends boolean>(options?: SchemaOptions<string, Optional>): Omit<StringSchema, "options"> & { options: NoInfer<typeof options>; }; export declare function number<Optional extends boolean>(options?: SchemaOptions<number, Optional>): Omit<NumberSchema, "options"> & { options: NoInfer<typeof options>; }; export declare function boolean<Optional extends boolean>(options?: SchemaOptions<boolean, Optional>): Omit<BooleanSchema, "options"> & { options: NoInfer<typeof options>; }; export { _undefined as undefined }; declare function _undefined<Optional extends boolean>(options?: SchemaOptions<undefined, Optional>): Omit<UndefinedSchema, "options"> & { options: NoInfer<typeof options>; }; export { _null as null }; declare function _null<Optional extends boolean>(options?: SchemaOptions<null, Optional>): Omit<NullSchema, "options"> & { options: NoInfer<typeof options>; }; export declare function nullish<Optional extends boolean>(options?: SchemaOptions<null | undefined, Optional>): Omit<NullishSchema, "options"> & { options: NoInfer<typeof options>; }; export { _function as function }; declare function _function<Optional extends boolean>(options?: SchemaOptions<(...args: any[]) => any, Optional>): Omit<FunctionSchema, "options"> & { options: NoInfer<typeof options>; }; export declare function instance<Constructor extends ObjectConstructor, Optional extends boolean>(constructor: Constructor, options?: SchemaOptions<InstanceType<Constructor>, Optional>): Omit<InstanceSchema<Constructor>, "options"> & { options: NoInfer<typeof options>; }; export declare function object<Shape extends ObjectShape, Optional extends boolean>(shape: Shape, options?: SchemaOptions<ObjectShapeToOutput<Shape>, Optional>): Omit<ObjectSchema<Shape>, "options"> & { options: NoInfer<typeof options>; }; export declare function array<Item extends Schema<any>, Optional extends boolean>(items: Item | Item[], options?: SchemaOptions<StandardSchemaV1.InferOutput<Item>[], Optional>): Omit<ArraySchema<Item>, "options"> & { options: NoInfer<typeof options>; }; export declare function union<Member extends Schema<any>, Optional extends boolean>(members: Member | Member[], options?: SchemaOptions<StandardSchemaV1.InferOutput<Member>, Optional>): Omit<UnionSchema<Member>, "options"> & { options: NoInfer<typeof options>; }; export declare function record<Value extends Schema<any>, Optional extends boolean>(values: Value | Value[], options?: SchemaOptions<Record<string, StandardSchemaV1.InferOutput<Value>>, Optional>): Omit<RecordSchema<Value>, "options"> & { options: NoInfer<typeof options>; }; export declare function set<Value extends Schema<any>, Optional extends boolean>(values: Value | Value[], options?: SchemaOptions<Set<StandardSchemaV1.InferOutput<Value>>, Optional>): Omit<SetSchema<Value>, "options"> & { options: NoInfer<typeof options>; }; export declare function map<Key extends Schema<any>, Value extends Schema<any>, Optional extends boolean>(keys: Key | Key[], values: Value | Value[], options?: SchemaOptions<Map<StandardSchemaV1.InferOutput<Key>, StandardSchemaV1.InferOutput<Value>>, Optional>): Omit<MapSchema<Key, Value>, "options"> & { options: NoInfer<typeof options>; };