From 2e1f2f92831616b0ca5d8b33d7068f5e968f8e1d Mon Sep 17 00:00:00 2001 From: Ilana Shapiro Date: Thu, 11 May 2023 00:35:29 -0700 Subject: [PATCH 1/2] add zod to set of validators --- package.json | 3 ++- validators.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c3ef1a..cb53433 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "json-stringify-safe": "^5.0.1", "jsonschema": "*", "JSV": "*", - "lodash": "^4.17.20", + "lodash": "^4.17.21", "mustache": "^4.0.1", "npm": "^6.14.9", "request-validator": "*", @@ -33,6 +33,7 @@ "skeemas": "*", "themis": "*", "tv4": "*", + "zod": "*", "z-schema": "*" }, "description": "Benchmarks for Node.js JSON-schema validators", diff --git a/validators.js b/validators.js index be72793..5f1e763 100644 --- a/validators.js +++ b/validators.js @@ -22,6 +22,7 @@ const djv = require("djv")(); const jsvg = require("json-schema-validator-generator").default; const jlib = require("json-schema-library"); const schemasafe = require("@exodus/schemasafe"); +const zod = require("zod"); let cfworker; module.exports = async function valivators(draftUri, draftVersion) { @@ -307,6 +308,15 @@ module.exports = async function valivators(draftUri, draftVersion) { return instance(json); }, }, + { + name: "zod", + setup: function(schema) { + return zod.inferType(schema); + }, + test: function(instance, json, schema) { + return instance.parse(json); + }, + }, { name: "@cfworker/json-schema", setup: (schema) => { From 08085c053551d1cab5c30992c2973ac7b9f7fc99 Mon Sep 17 00:00:00 2001 From: Ilana Shapiro Date: Thu, 11 May 2023 00:45:39 -0700 Subject: [PATCH 2/2] restore lodash version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cb53433..26c11f7 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "json-stringify-safe": "^5.0.1", "jsonschema": "*", "JSV": "*", - "lodash": "^4.17.21", + "lodash": "^4.17.20", "mustache": "^4.0.1", "npm": "^6.14.9", "request-validator": "*",