Comparing version 1.8.0 to 1.8.1
@@ -1,4 +0,3 @@ | ||
import { NullableType } from './types'; | ||
import { ValidationError, Type, StringType, NumberType, LiteralType, ObjectType, ArrayType, UnionType, PartialType, TupleType, DateType, LazyType, UndefinedType, NullType, 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 } 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, } from './types'; | ||
export declare const string: (opts?: StringOptions | undefined) => StringType; | ||
@@ -77,2 +76,12 @@ export declare const boolean: () => BooleanType; | ||
keySignature: typeof keySignature; | ||
NumberType: typeof NumberType; | ||
BooleanType: typeof BooleanType; | ||
StringType: typeof StringType; | ||
UndefinedType: typeof UndefinedType; | ||
NullType: typeof NullType; | ||
ObjectType: typeof ObjectType; | ||
ArrayType: typeof ArrayType; | ||
TupleType: typeof TupleType; | ||
NullableType: typeof NullableType; | ||
OptionalType: typeof OptionalType; | ||
}; | ||
@@ -79,0 +88,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.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.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"); | ||
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; } }); | ||
const string = (opts) => new types_2.StringType(opts); | ||
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; } }); | ||
// 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; } }); | ||
const string = (opts) => new types_1.StringType(opts); | ||
exports.string = string; | ||
const boolean = () => new types_2.BooleanType(); | ||
const boolean = () => new types_1.BooleanType(); | ||
exports.boolean = boolean; | ||
const number = (opts) => new types_2.NumberType(opts); | ||
const number = (opts) => new types_1.NumberType(opts); | ||
exports.number = number; | ||
const bigint = (opts) => new types_2.BigIntType(opts); | ||
const bigint = (opts) => new types_1.BigIntType(opts); | ||
exports.bigint = bigint; | ||
const unknown = () => new types_2.UnknownType(); | ||
const unknown = () => new types_1.UnknownType(); | ||
exports.unknown = unknown; | ||
const literal = (literal) => new types_2.LiteralType(literal); | ||
const literal = (literal) => new types_1.LiteralType(literal); | ||
exports.literal = literal; | ||
const object = (shape, opts) => new types_2.ObjectType(shape, opts); | ||
const object = (shape, opts) => new types_1.ObjectType(shape, opts); | ||
exports.object = object; | ||
const array = (schema, opts) => new types_2.ArrayType(schema, opts); | ||
const array = (schema, opts) => new types_1.ArrayType(schema, opts); | ||
exports.array = array; | ||
const union = (schemas, opts) => new types_2.UnionType(schemas, opts); | ||
const union = (schemas, opts) => new types_1.UnionType(schemas, opts); | ||
exports.union = union; | ||
const intersection = (l, r) => l.and(r); | ||
exports.intersection = intersection; | ||
const literals = (...args) => new types_2.UnionType(args.map(exports.literal)); | ||
const literals = (...args) => new types_1.UnionType(args.map(exports.literal)); | ||
exports.literals = literals; | ||
const record = (schema) => new types_2.ObjectType({ [types_2.keySignature]: schema }); | ||
const record = (schema) => new types_1.ObjectType({ [types_1.keySignature]: schema }); | ||
exports.record = record; | ||
const dictionary = (schema) => { | ||
if (schema instanceof types_2.OptionalType) { | ||
return new types_2.ObjectType({ [types_2.keySignature]: schema }); | ||
if (schema instanceof types_1.OptionalType) { | ||
return new types_1.ObjectType({ [types_1.keySignature]: schema }); | ||
} | ||
return new types_2.ObjectType({ [types_2.keySignature]: new types_2.OptionalType(schema) }); | ||
return new types_1.ObjectType({ [types_1.keySignature]: new types_1.OptionalType(schema) }); | ||
}; | ||
exports.dictionary = dictionary; | ||
const tuple = (schemas) => new types_2.TupleType(schemas); | ||
const tuple = (schemas) => new types_1.TupleType(schemas); | ||
exports.tuple = tuple; | ||
const date = () => new types_2.DateType(); | ||
const date = () => new types_1.DateType(); | ||
exports.date = date; | ||
const lazy = (fn) => new types_2.LazyType(fn); | ||
const lazy = (fn) => new types_1.LazyType(fn); | ||
exports.lazy = lazy; | ||
function partial(schema, opts) { | ||
if (schema instanceof types_2.ObjectType) { | ||
if (schema instanceof types_1.ObjectType) { | ||
return schema.partial(opts); | ||
} | ||
return new types_2.PartialType(schema, opts); | ||
return new types_1.PartialType(schema, opts); | ||
} | ||
@@ -62,11 +72,11 @@ exports.partial = partial; | ||
exports.omit = omit; | ||
const undefinedValue = () => new types_2.UndefinedType(); | ||
const undefinedValue = () => new types_1.UndefinedType(); | ||
exports.undefined = undefinedValue; | ||
const nullValue = () => new types_2.NullType(); | ||
const nullValue = () => new types_1.NullType(); | ||
exports.null = nullValue; | ||
const enumValue = (e, opts) => new types_2.EnumType(e, opts); | ||
const enumValue = (e, opts) => new types_1.EnumType(e, opts); | ||
exports.enum = enumValue; | ||
// Support default imports | ||
exports.default = { | ||
Type: types_2.Type, | ||
Type: types_1.Type, | ||
string: exports.string, | ||
@@ -95,4 +105,15 @@ boolean: exports.boolean, | ||
enum: enumValue, | ||
ValidationError: types_2.ValidationError, | ||
keySignature: types_2.keySignature, | ||
ValidationError: types_1.ValidationError, | ||
keySignature: types_1.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, | ||
}; | ||
@@ -103,3 +124,3 @@ function required(schema) { | ||
} | ||
if (schema instanceof types_2.OptionalType) { | ||
if (schema instanceof types_1.OptionalType) { | ||
return required(schema.required()); | ||
@@ -106,0 +127,0 @@ } |
{ | ||
"name": "myzod", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./libs/index.js", |
109643
1912