@conform-to/yup
Advanced tools
Comparing version 1.0.0-pre.6 to 1.0.0-pre.7
@@ -1,11 +0,11 @@ | ||
import { type Constraint, type FormControl, type Submission } from '@conform-to/dom'; | ||
import { type Constraint, type Intent, type Submission } from '@conform-to/dom'; | ||
import * as yup from 'yup'; | ||
export declare function getFieldsetConstraint<Source extends yup.AnyObjectSchema>(source: Source): Record<string, Constraint>; | ||
export declare function getYupConstraint<Source extends yup.AnyObjectSchema>(source: Source): Record<string, Constraint>; | ||
export declare function parseWithYup<Schema extends yup.AnyObjectSchema>(payload: FormData | URLSearchParams, config: { | ||
schema: Schema | ((control: FormControl | null) => Schema); | ||
schema: Schema | ((intent: Intent | null) => Schema); | ||
async?: false; | ||
}): Submission<yup.InferType<Schema>, string[]>; | ||
export declare function parseWithYup<Schema extends yup.AnyObjectSchema>(payload: FormData | URLSearchParams, config: { | ||
schema: Schema | ((control: FormControl | null) => Schema); | ||
schema: Schema | ((intent: Intent | null) => Schema); | ||
async: true; | ||
}): Promise<Submission<yup.InferType<Schema>, string[]>>; |
16
index.js
@@ -28,3 +28,3 @@ 'use strict'; | ||
function getFieldsetConstraint(source) { | ||
function getYupConstraint(source) { | ||
var description = source.describe(); | ||
@@ -74,3 +74,5 @@ return Object.fromEntries(Object.entries(description.fields).map(_ref => { | ||
case 'min': | ||
dom.invariant(typeof constraint.min !== 'string', 'min is not a number'); | ||
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)) { | ||
@@ -82,3 +84,5 @@ var _test$params7; | ||
case 'max': | ||
dom.invariant(typeof constraint.max !== 'string', 'max is not a number'); | ||
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)) { | ||
@@ -98,4 +102,4 @@ var _test$params9; | ||
return dom.parse(payload, { | ||
resolve(payload, control) { | ||
var schema = typeof config.schema === 'function' ? config.schema(control) : config.schema; | ||
resolve(payload, intent) { | ||
var schema = typeof config.schema === 'function' ? config.schema(intent) : config.schema; | ||
var resolveData = value => ({ | ||
@@ -134,3 +138,3 @@ value | ||
exports.getFieldsetConstraint = getFieldsetConstraint; | ||
exports.getYupConstraint = getYupConstraint; | ||
exports.parseWithYup = parseWithYup; |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-pre.6", | ||
"version": "1.0.0-pre.7", | ||
"main": "index.js", | ||
@@ -29,3 +29,3 @@ "module": "index.mjs", | ||
"peerDependencies": { | ||
"@conform-to/dom": "1.0.0-pre.6", | ||
"@conform-to/dom": "1.0.0-pre.7", | ||
"yup": ">=0.32.0" | ||
@@ -32,0 +32,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14165
248
33