UNPKG

dilswer

Version:

Blazingly fast data validation library with TypeScript integration.

103 lines (102 loc) 2.53 kB
// src/data-types/Type.ts import { ArrayType } from "./types/array.mjs"; import { BooleanType } from "./types/boolean.mjs"; import { CustomType } from "./types/custom.mjs"; import { DictType } from "./types/dict.mjs"; import { EnumType } from "./types/enum.mjs"; import { EnumMemberType } from "./types/enum-member.mjs"; import { FunctionType } from "./types/function.mjs"; import { InstanceOfType } from "./types/instance.mjs"; import { IntegerType } from "./types/integer.mjs"; import { IntersectionType } from "./types/intersection.mjs"; import { LiteralType } from "./types/literal.mjs"; import { NullType } from "./types/null.mjs"; import { NumberType } from "./types/number.mjs"; import { RecordType } from "./types/record.mjs"; import { RecursiveType } from "./types/recursive.mjs"; import { SetType } from "./types/set.mjs"; import { StringType } from "./types/string.mjs"; import { SymbolType } from "./types/symbol.mjs"; import { TupleType } from "./types/tuple.mjs"; import { UndefinedType } from "./types/undefined.mjs"; import { UnionType } from "./types/union.mjs"; import { UnknownType } from "./types/unknown.mjs"; var Type = { get Unknown() { return new UnknownType(); }, get String() { return new StringType(); }, get Number() { return new NumberType(); }, get Int() { return new IntegerType(); }, get Boolean() { return new BooleanType(); }, get Symbol() { return new SymbolType(); }, get Function() { return new FunctionType(); }, get Null() { return new NullType(); }, get Undefined() { return new UndefinedType(); }, Record(args) { return new RecordType(args); }, Dict(...args) { return new DictType(args); }, Array(...args) { return new ArrayType(args); }, Tuple(...args) { return new TupleType(args); }, Set(...args) { return new SetType(args); }, OneOf(...args) { return new UnionType(args); }, AllOf(...args) { return new IntersectionType(args); }, Literal(value) { return new LiteralType(value); }, EnumMember(enumMember) { return new EnumMemberType(enumMember); }, Enum(enumInstance) { return new EnumType(enumInstance); }, InstanceOf(instanceOf) { return new InstanceOfType(instanceOf); }, Custom(validateFunction) { return new CustomType(validateFunction); }, Recursive(getDataType) { return new RecursiveType(getDataType); }, Option(type) { return { type, required: false }; } }; export { Type };