Comparing version 1.8.3 to 1.8.4
@@ -0,3 +1,4 @@ | ||
import { IntersectionType } from './types'; | ||
import { ValidationError, Type, StringType, NumberType, LiteralType, ObjectType, ArrayType, UnionType, PartialType, TupleType, DateType, LazyType, UndefinedType, NullType, NullableType, EnumType, BooleanType, UnknownType, NumberOptions, Literal, ObjectShape, ObjectOptions, AnyType, ArrayOptions, UnionOptions, PartialOpts, IntersectionResult, DeepPartialShape, PartialShape, Eval, ToUnion, keySignature, StringTypes, OptionalType, BigIntOptions, BigIntType, StringOptions, EnumOptions } from './types'; | ||
export { ValidationError, Type, Infer, keySignature, AnyType, ObjectShape, NumberType, BooleanType, StringType, UndefinedType, NullType, ObjectType, ArrayType, TupleType, NullableType, OptionalType, MappedType, DateType, } from './types'; | ||
export { ValidationError, Type, Infer, keySignature, AnyType, ObjectShape, NumberType, BooleanType, StringType, UndefinedType, NullType, ObjectType, ArrayType, TupleType, NullableType, OptionalType, MappedType, DateType, UnknownType, UnionType, IntersectionType, } from './types'; | ||
export declare const string: (opts?: StringOptions | undefined) => StringType; | ||
@@ -87,2 +88,5 @@ export declare const boolean: () => BooleanType; | ||
DateType: typeof DateType; | ||
UnknownType: typeof UnknownType; | ||
UnionType: typeof UnionType; | ||
IntersectionType: typeof IntersectionType; | ||
}; | ||
@@ -89,0 +93,0 @@ export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.required = exports.enum = exports.null = exports.undefined = exports.omit = exports.pick = exports.partial = exports.lazy = exports.date = exports.tuple = exports.dictionary = exports.record = exports.literals = exports.intersection = exports.union = exports.array = exports.object = exports.literal = exports.unknown = exports.bigint = exports.number = exports.boolean = exports.string = exports.DateType = exports.OptionalType = exports.NullableType = exports.TupleType = exports.ArrayType = exports.ObjectType = exports.NullType = exports.UndefinedType = exports.StringType = exports.BooleanType = exports.NumberType = exports.keySignature = exports.Type = exports.ValidationError = void 0; | ||
exports.required = exports.enum = exports.null = exports.undefined = exports.omit = exports.pick = exports.partial = exports.lazy = exports.date = exports.tuple = exports.dictionary = exports.record = exports.literals = exports.intersection = exports.union = exports.array = exports.object = exports.literal = exports.unknown = exports.bigint = exports.number = exports.boolean = exports.string = exports.IntersectionType = exports.UnionType = exports.UnknownType = exports.DateType = exports.OptionalType = exports.NullableType = exports.TupleType = exports.ArrayType = exports.ObjectType = exports.NullType = exports.UndefinedType = exports.StringType = exports.BooleanType = exports.NumberType = exports.keySignature = exports.Type = exports.ValidationError = void 0; | ||
const types_1 = require("./types"); | ||
var types_2 = require("./types"); | ||
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return types_2.ValidationError; } }); | ||
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return types_2.Type; } }); | ||
Object.defineProperty(exports, "keySignature", { enumerable: true, get: function () { return types_2.keySignature; } }); | ||
const types_2 = require("./types"); | ||
var types_3 = require("./types"); | ||
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return types_3.ValidationError; } }); | ||
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return types_3.Type; } }); | ||
Object.defineProperty(exports, "keySignature", { enumerable: true, get: function () { return types_3.keySignature; } }); | ||
// Types | ||
Object.defineProperty(exports, "NumberType", { enumerable: true, get: function () { return types_2.NumberType; } }); | ||
Object.defineProperty(exports, "BooleanType", { enumerable: true, get: function () { return types_2.BooleanType; } }); | ||
Object.defineProperty(exports, "StringType", { enumerable: true, get: function () { return types_2.StringType; } }); | ||
Object.defineProperty(exports, "UndefinedType", { enumerable: true, get: function () { return types_2.UndefinedType; } }); | ||
Object.defineProperty(exports, "NullType", { enumerable: true, get: function () { return types_2.NullType; } }); | ||
Object.defineProperty(exports, "ObjectType", { enumerable: true, get: function () { return types_2.ObjectType; } }); | ||
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return types_2.ArrayType; } }); | ||
Object.defineProperty(exports, "TupleType", { enumerable: true, get: function () { return types_2.TupleType; } }); | ||
Object.defineProperty(exports, "NullableType", { enumerable: true, get: function () { return types_2.NullableType; } }); | ||
Object.defineProperty(exports, "OptionalType", { enumerable: true, get: function () { return types_2.OptionalType; } }); | ||
Object.defineProperty(exports, "DateType", { enumerable: true, get: function () { return types_2.DateType; } }); | ||
const string = (opts) => new types_1.StringType(opts); | ||
Object.defineProperty(exports, "NumberType", { enumerable: true, get: function () { return types_3.NumberType; } }); | ||
Object.defineProperty(exports, "BooleanType", { enumerable: true, get: function () { return types_3.BooleanType; } }); | ||
Object.defineProperty(exports, "StringType", { enumerable: true, get: function () { return types_3.StringType; } }); | ||
Object.defineProperty(exports, "UndefinedType", { enumerable: true, get: function () { return types_3.UndefinedType; } }); | ||
Object.defineProperty(exports, "NullType", { enumerable: true, get: function () { return types_3.NullType; } }); | ||
Object.defineProperty(exports, "ObjectType", { enumerable: true, get: function () { return types_3.ObjectType; } }); | ||
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return types_3.ArrayType; } }); | ||
Object.defineProperty(exports, "TupleType", { enumerable: true, get: function () { return types_3.TupleType; } }); | ||
Object.defineProperty(exports, "NullableType", { enumerable: true, get: function () { return types_3.NullableType; } }); | ||
Object.defineProperty(exports, "OptionalType", { enumerable: true, get: function () { return types_3.OptionalType; } }); | ||
Object.defineProperty(exports, "DateType", { enumerable: true, get: function () { return types_3.DateType; } }); | ||
Object.defineProperty(exports, "UnknownType", { enumerable: true, get: function () { return types_3.UnknownType; } }); | ||
Object.defineProperty(exports, "UnionType", { enumerable: true, get: function () { return types_3.UnionType; } }); | ||
Object.defineProperty(exports, "IntersectionType", { enumerable: true, get: function () { return types_3.IntersectionType; } }); | ||
const string = (opts) => new types_2.StringType(opts); | ||
exports.string = string; | ||
const boolean = () => new types_1.BooleanType(); | ||
const boolean = () => new types_2.BooleanType(); | ||
exports.boolean = boolean; | ||
const number = (opts) => new types_1.NumberType(opts); | ||
const number = (opts) => new types_2.NumberType(opts); | ||
exports.number = number; | ||
const bigint = (opts) => new types_1.BigIntType(opts); | ||
const bigint = (opts) => new types_2.BigIntType(opts); | ||
exports.bigint = bigint; | ||
const unknown = () => new types_1.UnknownType(); | ||
const unknown = () => new types_2.UnknownType(); | ||
exports.unknown = unknown; | ||
const literal = (literal) => new types_1.LiteralType(literal); | ||
const literal = (literal) => new types_2.LiteralType(literal); | ||
exports.literal = literal; | ||
const object = (shape, opts) => new types_1.ObjectType(shape, opts); | ||
const object = (shape, opts) => new types_2.ObjectType(shape, opts); | ||
exports.object = object; | ||
const array = (schema, opts) => new types_1.ArrayType(schema, opts); | ||
const array = (schema, opts) => new types_2.ArrayType(schema, opts); | ||
exports.array = array; | ||
const union = (schemas, opts) => new types_1.UnionType(schemas, opts); | ||
const union = (schemas, opts) => new types_2.UnionType(schemas, opts); | ||
exports.union = union; | ||
const intersection = (l, r) => l.and(r); | ||
exports.intersection = intersection; | ||
const literals = (...args) => new types_1.UnionType(args.map(exports.literal)); | ||
const literals = (...args) => new types_2.UnionType(args.map(exports.literal)); | ||
exports.literals = literals; | ||
const record = (schema) => new types_1.ObjectType({ [types_1.keySignature]: schema }); | ||
const record = (schema) => new types_2.ObjectType({ [types_2.keySignature]: schema }); | ||
exports.record = record; | ||
const dictionary = (schema) => { | ||
if (schema instanceof types_1.OptionalType) { | ||
return new types_1.ObjectType({ [types_1.keySignature]: schema }); | ||
if (schema instanceof types_2.OptionalType) { | ||
return new types_2.ObjectType({ [types_2.keySignature]: schema }); | ||
} | ||
return new types_1.ObjectType({ [types_1.keySignature]: new types_1.OptionalType(schema) }); | ||
return new types_2.ObjectType({ [types_2.keySignature]: new types_2.OptionalType(schema) }); | ||
}; | ||
exports.dictionary = dictionary; | ||
const tuple = (schemas) => new types_1.TupleType(schemas); | ||
const tuple = (schemas) => new types_2.TupleType(schemas); | ||
exports.tuple = tuple; | ||
const date = () => new types_1.DateType(); | ||
const date = () => new types_2.DateType(); | ||
exports.date = date; | ||
const lazy = (fn) => new types_1.LazyType(fn); | ||
const lazy = (fn) => new types_2.LazyType(fn); | ||
exports.lazy = lazy; | ||
function partial(schema, opts) { | ||
if (schema instanceof types_1.ObjectType) { | ||
if (schema instanceof types_2.ObjectType) { | ||
return schema.partial(opts); | ||
} | ||
return new types_1.PartialType(schema, opts); | ||
return new types_2.PartialType(schema, opts); | ||
} | ||
@@ -73,11 +77,11 @@ exports.partial = partial; | ||
exports.omit = omit; | ||
const undefinedValue = () => new types_1.UndefinedType(); | ||
const undefinedValue = () => new types_2.UndefinedType(); | ||
exports.undefined = undefinedValue; | ||
const nullValue = () => new types_1.NullType(); | ||
const nullValue = () => new types_2.NullType(); | ||
exports.null = nullValue; | ||
const enumValue = (e, opts) => new types_1.EnumType(e, opts); | ||
const enumValue = (e, opts) => new types_2.EnumType(e, opts); | ||
exports.enum = enumValue; | ||
// Support default imports | ||
exports.default = { | ||
Type: types_1.Type, | ||
Type: types_2.Type, | ||
string: exports.string, | ||
@@ -106,22 +110,25 @@ boolean: exports.boolean, | ||
enum: enumValue, | ||
ValidationError: types_1.ValidationError, | ||
keySignature: types_1.keySignature, | ||
ValidationError: types_2.ValidationError, | ||
keySignature: types_2.keySignature, | ||
// types | ||
NumberType: types_1.NumberType, | ||
BooleanType: types_1.BooleanType, | ||
StringType: types_1.StringType, | ||
UndefinedType: types_1.UndefinedType, | ||
NullType: types_1.NullType, | ||
ObjectType: types_1.ObjectType, | ||
ArrayType: types_1.ArrayType, | ||
TupleType: types_1.TupleType, | ||
NullableType: types_1.NullableType, | ||
OptionalType: types_1.OptionalType, | ||
DateType: types_1.DateType, | ||
NumberType: types_2.NumberType, | ||
BooleanType: types_2.BooleanType, | ||
StringType: types_2.StringType, | ||
UndefinedType: types_2.UndefinedType, | ||
NullType: types_2.NullType, | ||
ObjectType: types_2.ObjectType, | ||
ArrayType: types_2.ArrayType, | ||
TupleType: types_2.TupleType, | ||
NullableType: types_2.NullableType, | ||
OptionalType: types_2.OptionalType, | ||
DateType: types_2.DateType, | ||
UnknownType: types_2.UnknownType, | ||
UnionType: types_2.UnionType, | ||
IntersectionType: types_1.IntersectionType, | ||
}; | ||
function required(schema) { | ||
if (schema instanceof types_1.NullableType) { | ||
if (schema instanceof types_2.NullableType) { | ||
return required(schema.required()); | ||
} | ||
if (schema instanceof types_1.OptionalType) { | ||
if (schema instanceof types_2.OptionalType) { | ||
return required(schema.required()); | ||
@@ -128,0 +135,0 @@ } |
{ | ||
"name": "myzod", | ||
"version": "1.8.3", | ||
"version": "1.8.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./libs/index.js", |
110658
1926