Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zod

Package Overview
Dependencies
Maintainers
1
Versions
364
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

12

lib/index.d.ts

@@ -23,11 +23,11 @@ import { ZodString, ZodStringDef } from './types/string';

declare const nullType: () => ZodNull;
declare const arrayType: <T extends ZodAny>(schema: T) => ZodArray<T>;
declare const arrayType: <T extends ZodType<any, import("./types/base").ZodTypeDef>>(schema: T) => ZodArray<T>;
declare const objectType: <T extends import("./types/base").ZodRawShape>(shape: T) => ZodObject<T, {
strict: true;
}>;
declare const unionType: <T extends [ZodAny, ZodAny, ...ZodAny[]]>(types: T) => ZodUnion<T>;
declare const intersectionType: <T extends ZodAny, U extends ZodAny>(left: T, right: U) => ZodIntersection<T, U>;
declare const tupleType: <T extends [] | [ZodAny, ...ZodAny[]]>(schemas: T) => ZodTuple<T>;
declare const functionType: <T extends ZodTuple<any>, U extends ZodAny>(args: T, returns: U) => ZodFunction<T, U>;
declare const lazyType: <T extends ZodAny>(getter: () => T) => ZodLazy<T>;
declare const unionType: <T extends [ZodType<any, import("./types/base").ZodTypeDef>, ZodType<any, import("./types/base").ZodTypeDef>, ...ZodType<any, import("./types/base").ZodTypeDef>[]]>(types: T) => ZodUnion<T>;
declare const intersectionType: <T extends ZodType<any, import("./types/base").ZodTypeDef>, U extends ZodType<any, import("./types/base").ZodTypeDef>>(left: T, right: U) => ZodIntersection<T, U>;
declare const tupleType: <T extends [ZodType<any, import("./types/base").ZodTypeDef>, ...ZodType<any, import("./types/base").ZodTypeDef>[]] | []>(schemas: T) => ZodTuple<T>;
declare const functionType: <T extends ZodTuple<any>, U extends ZodType<any, import("./types/base").ZodTypeDef>>(args: T, returns: U) => ZodFunction<T, U>;
declare const lazyType: <T extends ZodType<any, import("./types/base").ZodTypeDef>>(getter: () => T) => ZodLazy<T>;
declare const literalType: <T extends string | number | boolean | null | undefined>(value: T) => ZodLiteral<T>;

@@ -34,0 +34,0 @@ declare const enumType: <T extends [ZodLiteral<string>, ...ZodLiteral<string>[]]>(values: T) => ZodEnum<T>;

@@ -12,5 +12,5 @@ "use strict";

var ZodError_1 = require("./ZodError");
function assertNever(x) {
throw ZodError_1.ZodError.fromString('Unexpected object: ' + x);
}
// function assertNever(x: never): never {
// throw ZodError.fromString('Unexpected object: ' + x);
// }
exports.ZodParser = function (schemaDef) { return function (obj) {

@@ -178,8 +178,13 @@ var def = schemaDef;

throw ZodError_1.ZodError.fromString("\"" + obj + "\" does not match any value in enum");
case z.ZodTypes.function:
// case z.ZodTypes.function:
// return obj;
default:
// function
return obj;
default:
assertNever(def);
// assertNever(def);
// break;
}
// assertNever();
// return obj;
}; };
//# sourceMappingURL=parser.js.map

@@ -11,2 +11,12 @@ "use strict";

var z = __importStar(require("."));
// import zod from ".";
// const objLit = z.literal({
// asdf: 'adsf',
// qwer: ['sdf', 1234],
// lkjl: {
// qwer: {
// oiuwer: [5, 3, { asdf: ['12'] }],
// },
// },
// });
var dogSchema = z

@@ -13,0 +23,0 @@ .object({

@@ -19,3 +19,3 @@ import * as z from './base';

nonempty: () => ZodNonEmptyArray<T>;
static create: <T_1 extends z.ZodAny>(schema: T_1) => ZodArray<T_1>;
static create: <T_1 extends z.ZodType<any, z.ZodTypeDef>>(schema: T_1) => ZodArray<T_1>;
}

@@ -29,3 +29,3 @@ export declare class ZodNonEmptyArray<T extends z.ZodAny> extends z.ZodType<[T['_type'], ...T['_type'][]], ZodArrayDef<T>> {

nullable: () => ZodUnion<[this, ZodNull]>;
static create: <T_1 extends z.ZodAny>(schema: T_1) => ZodArray<T_1>;
static create: <T_1 extends z.ZodType<any, z.ZodTypeDef>>(schema: T_1) => ZodArray<T_1>;
}

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -53,3 +53,3 @@ extendStatics(d, b);

_this.nonempty = function () {
return new ZodNonEmptyArray(__assign(__assign({}, _this._def), { nonempty: true }));
return new ZodNonEmptyArray(__assign({}, _this._def, { nonempty: true }));
};

@@ -56,0 +56,0 @@ return _this;

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -20,7 +20,7 @@ import * as z from './base';

toJSON: () => ZodEnumDef<T>;
get Values(): {
readonly Values: {
[k in StringValues<T>]: k;
};
static create: <T_1 extends EnumValues>(values: T_1) => ZodEnum<T_1>;
static create: <T_1 extends [ZodLiteral<string>, ...ZodLiteral<string>[]]>(values: T_1) => ZodEnum<T_1>;
}
export {};

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -12,3 +12,3 @@ import * as z from './base';

validate: (func: z.TypeOfFunction<Args, Returns>) => z.TypeOfFunction<Args, Returns>;
static create: <T extends ZodTuple<any>, U extends z.ZodAny>(args: T, returns: U) => ZodFunction<T, U>;
static create: <T extends ZodTuple<any>, U extends z.ZodType<any, z.ZodTypeDef>>(args: T, returns: U) => ZodFunction<T, U>;
}

@@ -18,3 +18,3 @@ import * as z from './base';

};
static create: <T_1 extends z.ZodAny, U_1 extends z.ZodAny>(left: T_1, right: U_1) => ZodIntersection<T_1, U_1>;
static create: <T_1 extends z.ZodType<any, z.ZodTypeDef>, U_1 extends z.ZodType<any, z.ZodTypeDef>>(left: T_1, right: U_1) => ZodIntersection<T_1, U_1>;
}

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -10,7 +10,7 @@ import * as z from './base';

export declare class ZodLazy<T extends z.ZodAny> extends z.ZodType<z.TypeOf<T>, ZodLazyDef<T>> {
get schema(): T;
readonly schema: T;
optional: () => ZodUnion<[this, ZodUndefined]>;
nullable: () => ZodUnion<[this, ZodNull]>;
toJSON: () => never;
static create: <T_1 extends z.ZodAny>(getter: () => T_1) => ZodLazy<T_1>;
static create: <T_1 extends z.ZodType<any, z.ZodTypeDef>>(getter: () => T_1) => ZodLazy<T_1>;
}

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -23,3 +23,3 @@ import * as z from './base';

};
declare type Flatten<T extends z.ZodRawShape> = {
declare type Flatten<T extends object> = {
[k in keyof T]: T[k];

@@ -26,0 +26,0 @@ };

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -49,3 +49,3 @@ extendStatics(d, b);

}
return __assign(__assign(__assign({}, first), second), sharedShape);
return __assign({}, first, second, sharedShape);
};

@@ -70,3 +70,2 @@ var mergeObjects = function (first) { return function (second) {

}); };
// type SetKeyTest = SetKey<{asdf:string},"asdf",number>;
var ZodObject = /** @class */ (function (_super) {

@@ -73,0 +72,0 @@ __extends(ZodObject, _super);

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -16,3 +16,3 @@ import * as z from './base';

nullable: () => ZodUnion<[this, ZodNull]>;
static create: <T_1 extends [] | [z.ZodAny, ...z.ZodAny[]]>(schemas: T_1) => ZodTuple<T_1>;
static create: <T_1 extends [z.ZodType<any, z.ZodTypeDef>, ...z.ZodType<any, z.ZodTypeDef>[]] | []>(schemas: T_1) => ZodTuple<T_1>;
}

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -15,3 +15,3 @@ import * as z from './base';

};
static create: <T_1 extends [z.ZodAny, z.ZodAny, ...z.ZodAny[]]>(types: T_1) => ZodUnion<T_1>;
static create: <T_1 extends [z.ZodType<any, z.ZodTypeDef>, z.ZodType<any, z.ZodTypeDef>, ...z.ZodType<any, z.ZodTypeDef>[]]>(types: T_1) => ZodUnion<T_1>;
}

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -11,0 +11,0 @@ extendStatics(d, b);

@@ -8,5 +8,8 @@ declare type ZodErrorArray = {

constructor();
static create: (errors: ZodErrorArray) => ZodError;
get message(): string;
get empty(): boolean;
static create: (errors: {
path: (string | number)[];
message: string;
}[]) => ZodError;
readonly message: string;
readonly empty: boolean;
static fromString: (message: string) => ZodError;

@@ -13,0 +16,0 @@ mergeChild: (pathElement: string | number, child: ZodError) => void;

@@ -8,3 +8,3 @@ "use strict";

return extendStatics(d, b);
};
}
return function (d, b) {

@@ -16,9 +16,2 @@ extendStatics(d, b);

})();
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -36,10 +29,10 @@ var ZodError = /** @class */ (function (_super) {

return ZodError.create(_this.errors.map(function (err) {
return { path: __spreadArrays([pathElement], err.path), message: err.message };
return { path: [pathElement].concat(err.path), message: err.message };
}));
};
_this.addError = function (path, message) {
_this.errors = __spreadArrays(_this.errors, [{ path: [path], message: message }]);
_this.errors = _this.errors.concat([{ path: [path], message: message }]);
};
_this.merge = function (error) {
_this.errors = __spreadArrays(_this.errors, error.errors);
_this.errors = _this.errors.concat(error.errors);
};

@@ -46,0 +39,0 @@ // restore prototype chain

{
"name": "zod",
"version": "1.0.13",
"version": "1.0.14",
"description": "TypeScript-first schema declaration and validation library with static type inference",

@@ -60,4 +60,4 @@ "main": "./lib/index.js",

"tslint-config-prettier": "^1.18.0",
"typescript": "^3.8.3"
"typescript": "3.1"
}
}

@@ -1,5 +0,6 @@

# Zod
<p align="center">
<img src="logo.svg" width="200px" align="center" />
<h1 align="center">Zod</h1>
</p>
<img src="logo.svg" alt="logo" width="200"/>
### Table of contents

@@ -45,3 +46,3 @@

Zod 1.0.x is compatible with TypeScript 3.0+.
Zod 1.0.x is compatible with TypeScript 3.1+.

@@ -80,3 +81,3 @@ # Usage

const twelve = z.literal(12); // => ZodType<12>
const tru = z.boolean(true); // => ZodType<true>
const tru = z.literal(true); // => ZodType<true>
```

@@ -83,0 +84,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc