Socket
Socket
Sign inDemoInstall

@conform-to/zod

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@conform-to/zod - npm Package Compare versions

Comparing version 0.7.0-pre.1 to 0.7.0-pre.2

62

index.js

@@ -30,14 +30,2 @@ 'use strict';

function getFieldsetConstraint(source) {
function getSchemaShape(schema) {
if (schema instanceof z__namespace.ZodObject) {
return schema.shape;
} else if (schema instanceof z__namespace.ZodEffects) {
return getSchemaShape(schema.innerType());
} else if (schema instanceof z__namespace.ZodOptional) {
return getSchemaShape(schema.unwrap());
} else if (schema instanceof z__namespace.ZodIntersection) {
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, getSchemaShape(schema._def.left)), getSchemaShape(schema._def.right));
}
return null;
}
function inferConstraint(schema) {

@@ -104,11 +92,47 @@ var constraint = {};

}
var shape = getSchemaShape(source);
var result = {};
if (shape) {
for (var [key, def] of Object.entries(shape)) {
// @ts-expect-error
result[key] = inferConstraint(def);
var keys = ['required', 'minLength', 'maxLength', 'min', 'max', 'step', 'multiple', 'pattern'];
function resolveFieldsetConstarint(schema) {
if (schema instanceof z__namespace.ZodObject) {
var result = {};
for (var [key, def] of Object.entries(schema.shape)) {
// @ts-expect-error
result[key] = inferConstraint(def);
}
return result;
}
if (schema instanceof z__namespace.ZodEffects) {
return resolveFieldsetConstarint(schema.innerType());
} else if (schema instanceof z__namespace.ZodOptional) {
return resolveFieldsetConstarint(schema.unwrap());
} else if (schema instanceof z__namespace.ZodIntersection) {
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, resolveFieldsetConstarint(schema._def.left)), resolveFieldsetConstarint(schema._def.right));
} else if (schema instanceof z__namespace.ZodUnion || schema instanceof z__namespace.ZodDiscriminatedUnion) {
var options = schema.options;
return options.map(resolveFieldsetConstarint).reduce((prev, next) => {
var list = new Set([...Object.keys(prev), ...Object.keys(next)]);
var result = {};
for (var name of list) {
// @ts-expect-error
var prevConstraint = prev[name];
// @ts-expect-error
var nextConstraint = next[name];
if (prevConstraint && nextConstraint) {
result[name] = {};
for (var _key of keys) {
if (typeof prevConstraint[_key] !== 'undefined' && typeof nextConstraint[_key] !== 'undefined' && prevConstraint[_key] === nextConstraint[_key]) {
result[name][_key] = prevConstraint[_key];
}
}
} else {
result[name] = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, prevConstraint), nextConstraint), {}, {
required: false
});
}
}
return result;
});
}
return {};
}
return result;
return resolveFieldsetConstarint(source);
}

@@ -115,0 +139,0 @@ function parse(payload, config) {

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "0.7.0-pre.1",
"version": "0.7.0-pre.2",
"main": "index.js",

@@ -29,3 +29,3 @@ "module": "index.mjs",

"peerDependencies": {
"@conform-to/dom": "0.7.0-pre.1",
"@conform-to/dom": "0.7.0-pre.2",
"zod": "^3.21.0"

@@ -32,0 +32,0 @@ },

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