@effective-forms/yup
Advanced tools
+1
-4
| import { InferType, ObjectSchema, AnyObject } from 'yup'; | ||
| import { Schema } from '@effective-forms/core'; | ||
| interface Config<T extends ObjectSchema<object, AnyObject, object, "">> { | ||
| interface Config<T extends ObjectSchema<object, AnyObject, object, "">> extends Pick<Schema<InferType<T>>, 'validateOn' | 'clearOn'> { | ||
| schema: T; | ||
| initialValues: InferType<T>; | ||
| validateOn?: { | ||
| change: boolean; | ||
| }; | ||
| } | ||
| export declare function yupSchema<T extends ObjectSchema<object, AnyObject, object, "">>(config: Config<T>): Schema<InferType<T>>; | ||
| export {}; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){const n={fields:{},validator:a=>{try{e.schema.validateSync(a,{abortEarly:!1})}catch(r){const t={},s=r;for(const l of s.inner)t[l.path]=l.errors;return{result:!1,errors:t}}return{result:!0}},validateOn:e.validateOn};for(const a in e.schema.fields){const r=a;n.fields[r]={init:e.initialValues[r],validator:t=>{try{e.schema.validateSyncAt(r,{[r]:t})}catch(s){return{result:!1,errors:s.errors}}return{result:!0}}}}return n}exports.yupSchema=o; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(r){const n={fields:{},validator:a=>{try{r.schema.validateSync(a,{abortEarly:!1})}catch(e){const t={},l=e;for(const s of l.inner)t[s.path]=s.errors;return{result:!1,errors:t}}return{result:!0}},clearOn:r.clearOn,validateOn:r.validateOn};for(const a in r.schema.fields){const e=a;n.fields[e]={init:r.initialValues[e],validator:t=>{try{r.schema.validateSyncAt(e,{[e]:t})}catch(l){return{result:!1,errors:l.errors}}return{result:!0}}}}return n}exports.yupSchema=o; |
+12
-11
@@ -1,2 +0,2 @@ | ||
| function o(e) { | ||
| function o(r) { | ||
| const n = { | ||
@@ -6,5 +6,5 @@ fields: {}, | ||
| try { | ||
| e.schema.validateSync(a, { abortEarly: !1 }); | ||
| } catch (r) { | ||
| const t = {}, s = r; | ||
| r.schema.validateSync(a, { abortEarly: !1 }); | ||
| } catch (e) { | ||
| const t = {}, s = e; | ||
| for (const l of s.inner) | ||
@@ -16,12 +16,13 @@ t[l.path] = l.errors; | ||
| }, | ||
| validateOn: e.validateOn | ||
| clearOn: r.clearOn, | ||
| validateOn: r.validateOn | ||
| }; | ||
| for (const a in e.schema.fields) { | ||
| const r = a; | ||
| n.fields[r] = { | ||
| init: e.initialValues[r], | ||
| for (const a in r.schema.fields) { | ||
| const e = a; | ||
| n.fields[e] = { | ||
| init: r.initialValues[e], | ||
| validator: (t) => { | ||
| try { | ||
| e.schema.validateSyncAt(r, { | ||
| [r]: t | ||
| r.schema.validateSyncAt(e, { | ||
| [e]: t | ||
| }); | ||
@@ -28,0 +29,0 @@ } catch (s) { |
+1
-1
| { | ||
| "name": "@effective-forms/yup", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "type": "commonjs", | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
2737
1.94%49
-3.92%