Socket
Socket
Sign inDemoInstall

zod

Package Overview
Dependencies
Maintainers
1
Versions
361
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.11.0 to 1.11.1

2

CHANGELOG.md

@@ -5,3 +5,3 @@ # Changelog

| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| zod@1.11 | Introduced `.safeParse` option.<br>Introduced .regex method on string schemas.<br>Switched to `new URL()` constructor to check valid URLs.<br>Implemented `.primitives()` and `.nonprimitives()` on object schemas.<br>Implemented `z.nativeEnum()` for creating schemas from TypeScript `enum`s. |
| zod@1.11 | Introduced `.safeParse` option.<br>Introduced .regex method on string schemas.<br>Implemented `.primitives()` and `.nonprimitives()` on object schemas.<br>Implemented `z.nativeEnum()` for creating schemas from TypeScript `enum`s.<br>Switched to `new URL()` constructor to check valid URLs. |
| zod@1.10 | Dropping support for TypeScript 3.2 . |

@@ -8,0 +8,0 @@ | zod@1.9 | Added z.instanceof() and z.custom(). Implemented ZodSchema.array() method. |

@@ -8,3 +8,4 @@ export declare namespace util {

const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
const getValidEnumValues: (obj: any) => {}[];
const getValidEnumValues: (obj: any) => any[];
const getValues: (obj: any) => any[];
}

@@ -24,5 +24,10 @@ "use strict";

}
return Object.values(filtered);
return util.getValues(filtered);
};
util.getValues = function (obj) {
return Object.keys(obj).map(function (e) {
return obj[e];
});
};
})(util = exports.util || (exports.util = {}));
//# sourceMappingURL=util.js.map

@@ -122,2 +122,10 @@ "use strict";

]);
var find = function (arr, checker) {
for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
var item = arr_1[_i];
if (checker(item))
return item;
}
return undefined;
};
exports.ZodParser = function (schemaDef) { return function (obj, baseParams) {

@@ -140,6 +148,6 @@ if (baseParams === void 0) { baseParams = { seen: [], errorMap: defaultErrorMap_1.defaultErrorMap, path: [] }; }

var parsedType = exports.getParsedType(obj);
var schemaSeen = params.seen.find(function (x) { return x.schema === schemaDef; });
var schemaSeen = find(params.seen, function (x) { return x.schema === schemaDef; });
var isPrimitive = typeof obj !== 'object' || obj === null;
if (schemaSeen) {
var found = schemaSeen.objects.find(function (x) { return x.data === obj; });
var found = find(schemaSeen.objects, function (x) { return x.data === obj; });
if (found) {

@@ -375,3 +383,3 @@ if (found.error) {

code: ZodError_1.ZodErrorCode.invalid_enum_value,
options: Object.values(def.values),
options: util_1.util.getValues(def.values),
}));

@@ -378,0 +386,0 @@ }

"use strict";
// import * as z from '.';
// try {
// z.string().parse(1345);
// } catch (err) {
// console.log(err.message);
// console.log(err.flatten());
// }
//# sourceMappingURL=playground.js.map

@@ -72,10 +72,11 @@ "use strict";

get: function () {
return JSON.stringify(this.errors, null, 2);
// const errorMessage: string[] = [`${this.errors.length} validation issue(s)`, ''];
// for (const err of this.errors) {
// errorMessage.push(` Issue #${this.errors.indexOf(err)}: ${err.code} at ${err.path.join('./index')}`);
// errorMessage.push(` ` + err.message);
// errorMessage.push('');
// }
// return errorMessage.join('\n');
// return JSON.stringify(this.errors, null, 2);
var errorMessage = [this.errors.length + " validation issue(s)", ''];
for (var _i = 0, _a = this.errors; _i < _a.length; _i++) {
var err = _a[_i];
errorMessage.push(" Issue #" + this.errors.indexOf(err) + ": " + err.code + " at " + err.path.join('./index'));
errorMessage.push(" " + err.message);
errorMessage.push('');
}
return errorMessage.join('\n');
// return quotelessJson(this);

@@ -82,0 +83,0 @@ // .map(({ path, message }) => {

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

@@ -5,0 +5,0 @@ "main": "./lib/src/index.js",

@@ -25,4 +25,11 @@ <p align="center">

> ⚠️ You might be encountering issues building your project if you're using zod@<1.10.2. This is the result of a bug in the TypeScript compiler. To solve this without updating, set `"skipLibCheck": true` in your tsconfig.json "compilerOptions". This issue is resolved in zod@1.10.2 and later.
**Aug 30 — zod@1.11 was released with lots of cool features!**
- All schemas now have a `.safeParse` method. This lets you validate data in a more functional way, similar to `io-ts`: https://github.com/vriad/zod#safe-parse
- String schemas have a new `.regex` refinement method: https://github.com/vriad/zod#strings
- Object schemas now have two new methods: `.primitives()` and `.nonprimitives()`. These methods let you quickly pick or omit primitive fields from objects, useful for validating API inputs: https://github.com/vriad/zod#primitives-and-nonprimitives
- Zod now provides `z.nativeEnum()`, which lets you create z Zod schema from an existing TypeScript `enum`: https://github.com/vriad/zod#native-enums
<!-- > ⚠️ You might be encountering issues building your project if you're using zod@<1.10.2. This is the result of a bug in the TypeScript compiler. To solve this without updating, set `"skipLibCheck": true` in your tsconfig.json "compilerOptions". This issue is resolved in zod@1.10.2 and later. -->
# What is Zod

@@ -44,19 +51,3 @@

<table>
<tr>
<td align="center">
<a href="https://github.com/kevinsimper">
<img src="https://avatars0.githubusercontent.com/u/3084745" width="100px;" alt="" />
</a>
<br>
<b>Colin McDonnell</b>
<br>
<a href="https://twitter.com/vriad">@vriad</a>,
<span>creator of Zod</span>
</td>
<td>
I work on Zod in my free time, so if you're making money from a product that is built with Zod, I'd massively appreciate sponsorship at any level. For solo devs, I recommend the [Chipotle Bowl tier](https://github.com/sponsors/vriad) or the [Cup of Coffee tier](https://github.com/sponsors/vriad). If you're a freelancer or entrepreneur, get listed below and enjoy Zod can [help you with that](https://github.com/sponsors/vriad). Check out my GitHub Sponsors profile at [github.com/sponsors/vriad](github.com/sponsors/vriad).
</td>
</tr>
</table>
I work on Zod in my free time, so if you're making money from a product that is built with Zod, I'd massively appreciate sponsorship at any level. For solo devs, I recommend the [Chipotle Bowl tier](https://github.com/sponsors/vriad) or the [Cup of Coffee tier](https://github.com/sponsors/vriad). If you're a freelancer or entrepreneur, get listed below and enjoy Zod can [help you with that](https://github.com/sponsors/vriad). Check out my GitHub Sponsors profile at [github.com/sponsors/vriad](github.com/sponsors/vriad).

@@ -63,0 +54,0 @@ ### Sponsors

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