New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@conform-to/yup

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@conform-to/yup - npm Package Compare versions

Comparing version 1.1.0-pre.0 to 1.1.0

constraint.d.ts

4

index.d.ts

@@ -1,4 +0,4 @@

import { type Constraint, type Intent, type Submission } from '@conform-to/dom';
import { type Intent, type Submission } from '@conform-to/dom';
import * as yup from 'yup';
export declare function getYupConstraint<Source extends yup.AnyObjectSchema>(source: Source): Record<string, Constraint>;
export { getYupConstraint } from './constraint';
export declare function parseWithYup<Schema extends yup.AnyObjectSchema>(payload: FormData | URLSearchParams, config: {

@@ -5,0 +5,0 @@ schema: Schema | ((intent: Intent | null) => Schema);

@@ -7,2 +7,3 @@ 'use strict';

var yup = require('yup');
var constraint = require('./constraint.js');

@@ -29,71 +30,2 @@ function _interopNamespace(e) {

function getYupConstraint(source) {
var description = source.describe();
return Object.fromEntries(Object.entries(description.fields).map(_ref => {
var _test$params, _test$params3, _test$params5, _test$params6, _test$params8;
var [key, def] = _ref;
var constraint = {};
switch (def.type) {
case 'string':
{
for (var test of def.tests) {
switch (test.name) {
case 'required':
constraint.required = true;
break;
case 'min':
if (!constraint.minLength || constraint.minLength < Number((_test$params = test.params) === null || _test$params === void 0 ? void 0 : _test$params.min)) {
var _test$params2;
constraint.minLength = Number((_test$params2 = test.params) === null || _test$params2 === void 0 ? void 0 : _test$params2.min);
}
break;
case 'max':
if (!constraint.maxLength || constraint.maxLength > Number((_test$params3 = test.params) === null || _test$params3 === void 0 ? void 0 : _test$params3.max)) {
var _test$params4;
constraint.maxLength = Number((_test$params4 = test.params) === null || _test$params4 === void 0 ? void 0 : _test$params4.max);
}
break;
case 'matches':
if (!constraint.pattern && ((_test$params5 = test.params) === null || _test$params5 === void 0 ? void 0 : _test$params5.regex) instanceof RegExp) {
constraint.pattern = test.params.regex.source;
}
break;
}
}
if (!constraint.pattern && def.oneOf.length > 0) {
constraint.pattern = def.oneOf.join('|');
}
break;
}
case 'number':
for (var _test of def.tests) {
switch (_test.name) {
case 'required':
constraint.required = true;
break;
case 'min':
if (typeof constraint.min === 'string') {
throw new Error('min should not be a string');
}
if (!constraint.min || constraint.min < Number((_test$params6 = _test.params) === null || _test$params6 === void 0 ? void 0 : _test$params6.min)) {
var _test$params7;
constraint.min = Number((_test$params7 = _test.params) === null || _test$params7 === void 0 ? void 0 : _test$params7.min);
}
break;
case 'max':
if (typeof constraint.max === 'string') {
throw new Error('max should not be a number');
}
if (!constraint.max || constraint.max > Number((_test$params8 = _test.params) === null || _test$params8 === void 0 ? void 0 : _test$params8.max)) {
var _test$params9;
constraint.max = Number((_test$params9 = _test.params) === null || _test$params9 === void 0 ? void 0 : _test$params9.max);
}
break;
}
}
break;
}
return [key, constraint];
}));
}
function parseWithYup(payload, config) {

@@ -136,3 +68,3 @@ return dom.parse(payload, {

exports.getYupConstraint = getYupConstraint;
exports.getYupConstraint = constraint.getYupConstraint;
exports.parseWithYup = parseWithYup;

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

"license": "MIT",
"version": "1.1.0-pre.0",
"version": "1.1.0",
"main": "index.js",

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

"peerDependencies": {
"@conform-to/dom": "1.1.0-pre.0",
"@conform-to/dom": "1.1.0",
"yup": ">=0.32.0"

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

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