You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mobx-react-form

Package Overview
Dependencies
Maintainers
1
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-react-form - npm Package Compare versions

Comparing version

to
6.12.1

7

lib/Field.d.ts

@@ -56,3 +56,6 @@ import Base from "./Base";

validationFunctionsData: any[];
validationAsyncData: any;
validationAsyncData: {
valid: boolean;
message: any;
};
debouncedValidation: any;

@@ -114,3 +117,3 @@ disposeValidationOnBlur: any;

invalidate(message: string, deep?: boolean, async?: boolean): void;
setValidationAsyncData(valid?: boolean, message?: string): void;
setValidationAsyncData(valid?: boolean, message?: string | null): void;
resetValidation(deep?: boolean): void;

@@ -117,0 +120,0 @@ clear(deep?: boolean, execHook?: boolean): void;

@@ -391,3 +391,3 @@ "use strict";

writable: true,
value: void 0
value: { valid: true, message: null }
});

@@ -594,5 +594,3 @@ Object.defineProperty(this, "debouncedValidation", {

get checkValidationErrors() {
var _a;
return ((((_a = this.validationAsyncData) === null || _a === void 0 ? void 0 : _a.valid) === false &&
!lodash_1.default.isEmpty(this.validationAsyncData)) ||
return (!this.validationAsyncData.valid ||
!lodash_1.default.isEmpty(this.validationErrorStack) ||

@@ -891,3 +889,3 @@ lodash_1.default.isString(this.errorAsync) ||

}
setValidationAsyncData(valid = false, message = "") {
setValidationAsyncData(valid = false, message = null) {
this.validationAsyncData = { valid, message };

@@ -899,3 +897,3 @@ }

this.errorAsync = null;
this.validationAsyncData = undefined;
this.validationAsyncData = { valid: true, message: null };
this.validationFunctionsData = [];

@@ -964,6 +962,5 @@ this.validationErrorStack = [];

showErrors(show = true, deep = true) {
var _a, _b;
this.showError = show;
this.errorSync = lodash_1.default.head(this.validationErrorStack) || null;
this.errorAsync = (((_a = this.validationAsyncData) === null || _a === void 0 ? void 0 : _a.valid) === false) ? (_b = this.validationAsyncData) === null || _b === void 0 ? void 0 : _b.message : null;
this.errorAsync = !this.validationAsyncData.valid ? this.validationAsyncData.message : null;
deep && this.each((field) => field.showErrors(show, deep));

@@ -970,0 +967,0 @@ }

@@ -20,4 +20,4 @@ import { BaseInterface } from "./BaseInterface";

validationAsyncData: {
valid?: boolean;
message?: string | null;
valid: boolean;
message: string | null;
};

@@ -66,3 +66,3 @@ debouncedValidation: any;

invalidate(message?: string, deep?: boolean, async?: boolean): void;
setValidationAsyncData(valid?: boolean, message?: string): void;
setValidationAsyncData(valid: boolean, message?: string | null): void;
resetValidation(deep: boolean): void;

@@ -69,0 +69,0 @@ clear(deep?: boolean): void;

@@ -32,4 +32,4 @@ import { ObservableMap } from "mobx";

declare const isBool: ($: any, val: any) => boolean;
declare const $try: (...args: any) => any;
declare const $try: (...args: any[]) => any;
export { props, checkObserve, checkPropOccurrence, hasProps, allowedProps, throwError, isArrayOfStrings, isEmptyArray, isArrayOfObjects, pathToStruct, isArrayFromStruct, hasUnifiedProps, hasSeparatedProps, allowNested, parseIntKeys, hasIntKeys, maxKey, uniqueId, isEvent, hasFiles, isBool, $try, getObservableMapKeys, getObservableMapValues, };
//# sourceMappingURL=utils.d.ts.map

@@ -159,7 +159,9 @@ "use strict";

const $try = (...args) => {
let found = undefined;
args.map((val) => found === undefined && !lodash_1.default.isUndefined(val) && (found = val));
return found;
for (const val of args) {
if (val !== undefined)
return val;
}
return undefined;
};
exports.$try = $try;
//# sourceMappingURL=utils.js.map
import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";
import { ValidationPlugin, ValidationPluginConfig, ValidationPluginConstructor, ValidationPluginInterface } from "src/models/ValidatorInterface";

@@ -7,3 +8,3 @@ export declare class DVR<TValidator = any> implements ValidationPluginInterface<TValidator> {

config: any;
state: any;
state: StateInterface;
extend?: (args: {

@@ -10,0 +11,0 @@ validator: TValidator;

@@ -107,5 +107,4 @@ "use strict";

executeAsyncValidation(field) {
const asyncData = field.validationAsyncData;
if (asyncData.valid === false) {
field.invalidate(asyncData.message, false, true);
if (field.validationAsyncData.valid === false) {
field.invalidate(field.validationAsyncData.message, false, true);
}

@@ -112,0 +111,0 @@ }

import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";
import { ValidationPlugin, ValidationPluginConfig, ValidationPluginConstructor, ValidationPluginInterface } from "../models/ValidatorInterface";

@@ -7,3 +8,3 @@ export declare class VJF<TValidator = any> implements ValidationPluginInterface<TValidator> {

config: ValidationPluginConfig<TValidator>;
state: any;
state: StateInterface;
extend?: (args: {

@@ -10,0 +11,0 @@ validator: TValidator;

@@ -89,5 +89,4 @@ "use strict";

executeAsyncValidation(field) {
const data = field.validationAsyncData;
if (data.valid === false) {
field.invalidate(data.message, false, true);
if (field.validationAsyncData.valid === false) {
field.invalidate(field.validationAsyncData.message, false, true);
}

@@ -94,0 +93,0 @@ }

@@ -64,8 +64,8 @@ "use strict";

createValidationPromise(field) {
return new Promise((resolve) => this.validator
.reach(this.schema, field.path)
.label(field.label)
.validate(field.validatedValue, { strict: true })
.then(() => this.handleAsyncPasses(field, resolve))
.catch((error) => this.handleAsyncFails(field, resolve, error)));
return new Promise((resolve) => {
this.schema
.validateAt(field.path, this.state.form.values(), { strict: true })
.then(() => this.handleAsyncPasses(field, resolve))
.catch((error) => this.handleAsyncFails(field, resolve, error));
});
}

@@ -79,5 +79,11 @@ // Gestione dei successi della validazione asincrona

handleAsyncFails(field, resolve, error) {
field.setValidationAsyncData(false, error.errors[0]);
this.executeAsyncValidation(field);
resolve();
var _a, _b;
// Yup a volte restituisce errori senza path (es. array vuoti)
const isSameField = error.path === field.path || error.path === undefined;
if (isSameField) {
const message = (_a = error.message) === null || _a === void 0 ? void 0 : _a.replace((_b = error.path) !== null && _b !== void 0 ? _b : field.path, field.label);
field.setValidationAsyncData(false, message);
this.executeAsyncValidation(field);
}
resolve(undefined);
}

@@ -84,0 +90,0 @@ // Esecuzione della validazione asincrona

import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";
import { ZodSchema } from "zod";

@@ -8,3 +9,3 @@ import { ValidationPlugin, ValidationPluginConfig, ValidationPluginConstructor, ValidationPluginInterface } from "../models/ValidatorInterface";

config: ValidationPluginConfig;
state: any;
state: StateInterface;
extend?: (args: {

@@ -11,0 +12,0 @@ validator: TValidator;

{
"name": "mobx-react-form",
"license": "MIT",
"version": "6.12.0",
"version": "6.12.1",
"author": "Claudio Savino <claudio.savino@me.com> (https://twitter.com/foxhound87)",

@@ -6,0 +6,0 @@ "description": "Reactive MobX Form State Management",

@@ -169,3 +169,3 @@ import {

validationFunctionsData: any[] = [];
validationAsyncData: any;
validationAsyncData = { valid: true, message: null };
debouncedValidation: any;

@@ -292,4 +292,3 @@

return (
((this.validationAsyncData as any)?.valid === false &&
!_.isEmpty(this.validationAsyncData)) ||
!this.validationAsyncData.valid ||
!_.isEmpty(this.validationErrorStack) ||

@@ -748,3 +747,3 @@ _.isString(this.errorAsync) ||

setValidationAsyncData(valid: boolean = false, message: string = ""): void {
setValidationAsyncData(valid: boolean = false, message: string|null = null): void {
this.validationAsyncData = { valid, message };

@@ -757,3 +756,3 @@ }

this.errorAsync = null;
this.validationAsyncData = undefined;
this.validationAsyncData = { valid: true, message: null };
this.validationFunctionsData = [];

@@ -832,3 +831,3 @@ this.validationErrorStack = [];

this.errorSync = _.head(this.validationErrorStack) as string || null;
this.errorAsync = (this.validationAsyncData?.valid === false) ? this.validationAsyncData?.message as string : null
this.errorAsync = !this.validationAsyncData.valid ? this.validationAsyncData.message : null
deep && this.each((field: FieldInterface) => field.showErrors(show, deep));

@@ -835,0 +834,0 @@ }

@@ -19,3 +19,3 @@ import {BaseInterface} from "./BaseInterface";

validationFunctionsData: any[];
validationAsyncData: { valid?: boolean, message?: string | null;};
validationAsyncData: { valid: boolean, message: string | null };
debouncedValidation: any;

@@ -74,3 +74,3 @@ autoFocus: boolean;

invalidate(message?: string, deep?: boolean, async?: boolean): void;
setValidationAsyncData(valid?: boolean, message?: string): void;
setValidationAsyncData(valid: boolean, message?: string|null): void;
resetValidation(deep: boolean): void;

@@ -77,0 +77,0 @@ clear(deep?: boolean): void;

@@ -167,9 +167,7 @@ import _ from "lodash";

const $try = (...args: any) => {
let found: any | null | undefined = undefined;
args.map(( val: any ) =>
found === undefined && !_.isUndefined(val) && (found = val));
return found;
const $try = (...args: any[]) => {
for (const val of args) {
if (val !== undefined) return val;
}
return undefined;
};

@@ -176,0 +174,0 @@

import _ from "lodash";
import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";
import { ValidationPlugin, ValidationPluginConfig, ValidationPluginConstructor, ValidationPluginInterface } from "src/models/ValidatorInterface";

@@ -9,3 +10,3 @@

config: any;
state: any;
state: StateInterface;
extend?: (args: { validator: TValidator; form: FormInterface }) => void;

@@ -12,0 +13,0 @@ validator: TValidator;

import _ from "lodash";
import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";
import {

@@ -14,3 +15,3 @@ ValidationPlugin,

config: ValidationPluginConfig<TValidator>;
state: any;
state: StateInterface;
extend?: (args: { validator: TValidator; form: FormInterface }) => void;

@@ -17,0 +18,0 @@ validator: TValidator;

import _ from "lodash";
import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";
import {

@@ -22,3 +23,3 @@ ValidationPlugin,

config: ValidationPluginConfig<TValidator>;
state: any;
state: StateInterface;
extend?: (args: { validator: TValidator; form: FormInterface }) => void;

@@ -108,5 +109,4 @@ validator: any;

executeAsyncValidation(field: FieldInterface): void {
const asyncData = field.validationAsyncData;
if (asyncData.valid === false) {
field.invalidate(asyncData.message, false, true);
if (field.validationAsyncData.valid === false) {
field.invalidate(field.validationAsyncData.message, false, true);
}

@@ -113,0 +113,0 @@ }

import _ from "lodash";
import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";
import {

@@ -22,3 +23,3 @@ ValidationPlugin,

config: ValidationPluginConfig<TValidator>;
state: any;
state: StateInterface;
extend?: (args: { validator: TValidator; form: FormInterface }) => void;

@@ -86,5 +87,4 @@ validator: TValidator;

executeAsyncValidation(field: FieldInterface): void {
const data = field.validationAsyncData;
if (data.valid === false) {
field.invalidate(data.message, false, true);
if (field.validationAsyncData.valid === false) {
field.invalidate(field.validationAsyncData.message, false, true);
}

@@ -91,0 +91,0 @@ }

@@ -7,4 +7,4 @@ import {

} from "../models/ValidatorInterface";
import _ from "lodash";
import FormInterface from "src/models/FormInterface";
import StateInterface from "src/models/StateInterface";

@@ -14,3 +14,3 @@ class YUP<TValidator = any> implements ValidationPluginInterface {

config: ValidationPluginConfig<TValidator>;
state: any;
state: StateInterface;
extend?: (args: { validator: TValidator; form: FormInterface }) => void;

@@ -51,12 +51,9 @@ validator: TValidator;

private createValidationPromise(field: any): Promise<any> {
return new Promise((resolve) =>
(this.validator as any)
.reach(this.schema, field.path)
.label(field.label)
.validate(field.validatedValue, { strict: true })
return new Promise((resolve) => {
this.schema
.validateAt(field.path, this.state.form.values(), { strict: true })
.then(() => this.handleAsyncPasses(field, resolve))
.catch((error) => this.handleAsyncFails(field, resolve, error))
);
.catch((error) => this.handleAsyncFails(field, resolve, error));
});
}
// Gestione dei successi della validazione asincrona

@@ -70,5 +67,12 @@ private handleAsyncPasses(field: any, resolve: Function): void {

private handleAsyncFails(field: any, resolve: Function, error: any): void {
field.setValidationAsyncData(false, error.errors[0]);
this.executeAsyncValidation(field);
resolve();
// Yup a volte restituisce errori senza path (es. array vuoti)
const isSameField = error.path === field.path || error.path === undefined;
if (isSameField) {
const message = error.message?.replace(error.path ?? field.path, field.label);
field.setValidationAsyncData(false, message);
this.executeAsyncValidation(field);
}
resolve(undefined);
}

@@ -75,0 +79,0 @@

import _ from "lodash";
import FieldInterface from "src/models/FieldInterface";
import FormInterface from "src/models/FormInterface";
import { ZodSchema, ZodError } from "zod";
import StateInterface from "src/models/StateInterface";
import { ZodSchema } from "zod";
import {

@@ -15,3 +16,3 @@ ValidationPlugin,

config: ValidationPluginConfig;
state: any;
state: StateInterface;
extend?: (args: { validator: TValidator; form: FormInterface }) => void;

@@ -18,0 +19,0 @@ validator: any;

@@ -127,5 +127,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

executeAsyncValidation(field) {
const asyncData = field.validationAsyncData;
if (asyncData.valid === false) {
field.invalidate(asyncData.message, false, true);
if (field.validationAsyncData.valid === false) {
field.invalidate(field.validationAsyncData.message, false, true);
}

@@ -132,0 +131,0 @@ }

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("_")):"function"==typeof define&&define.amd?define(["_"],t):"object"==typeof exports?exports.MobxReactFormValidatorSVK=t(require("_")):e.MobxReactFormValidatorSVK=t(e._)}(self,(e=>(()=>{"use strict";var t={324:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=i(r(479));class o{constructor({config:e,state:t=null,promises:r=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=t,this.promises=r,this.config=e,this.extend=null==e?void 0:e.extend,this.schema=e.schema,this.initValidator()}extendOptions(e={}){return Object.assign(Object.assign({},e),{errorDataPath:"property",allErrors:!0,coerceTypes:!0,v5:!0})}initValidator(){const e=new(0,this.config.package)(this.extendOptions(this.config.options));"function"==typeof this.extend&&this.extend({form:this.state.form,validator:e}),this.validator=e.compile(this.schema)}validate(e){const t=this.validator(e.state.form.validatedValues);if(!(r=t)||"function"!=typeof r.then||"object"!=typeof r&&"function"!=typeof r){var r;this.handleSyncError(e,this.validator.errors)}else{const r=t.then((()=>e.setValidationAsyncData(!0))).catch((t=>t&&this.handleAsyncError(e,t.errors))).then((()=>this.executeAsyncValidation(e)));this.promises.push(r)}}handleSyncError(e,t){const r=this.findError(e.path,t);if(!r)return;const i=`${e.label} ${r.message}`;e.invalidate(i,!1)}handleAsyncError(e,t){const r=this.findError(e.path,t);if(!r)return;const i=`${e.label} ${r.message}`;e.setValidationAsyncData(!1,i)}findError(e,t){return a.default.find(t,(({dataPath:t})=>{let r;return r=a.default.trimStart(t,"."),r=a.default.replace(r,"]",""),r=a.default.replace(r,"[","."),a.default.includes(r,e)}))}executeAsyncValidation(e){const t=e.validationAsyncData;!1===t.valid&&e.invalidate(t.message,!1,!0)}}t.default=e=>({class:o,config:e})},479:t=>{t.exports=e}},r={};return function e(i){var a=r[i];if(void 0!==a)return a.exports;var o=r[i]={exports:{}};return t[i].call(o.exports,o,o.exports,e),o.exports}(324)})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("_")):"function"==typeof define&&define.amd?define(["_"],t):"object"==typeof exports?exports.MobxReactFormValidatorSVK=t(require("_")):e.MobxReactFormValidatorSVK=t(e._)}(self,(e=>(()=>{"use strict";var t={324:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=i(r(479));class o{constructor({config:e,state:t=null,promises:r=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=t,this.promises=r,this.config=e,this.extend=null==e?void 0:e.extend,this.schema=e.schema,this.initValidator()}extendOptions(e={}){return Object.assign(Object.assign({},e),{errorDataPath:"property",allErrors:!0,coerceTypes:!0,v5:!0})}initValidator(){const e=new(0,this.config.package)(this.extendOptions(this.config.options));"function"==typeof this.extend&&this.extend({form:this.state.form,validator:e}),this.validator=e.compile(this.schema)}validate(e){const t=this.validator(e.state.form.validatedValues);if(!(r=t)||"function"!=typeof r.then||"object"!=typeof r&&"function"!=typeof r){var r;this.handleSyncError(e,this.validator.errors)}else{const r=t.then((()=>e.setValidationAsyncData(!0))).catch((t=>t&&this.handleAsyncError(e,t.errors))).then((()=>this.executeAsyncValidation(e)));this.promises.push(r)}}handleSyncError(e,t){const r=this.findError(e.path,t);if(!r)return;const i=`${e.label} ${r.message}`;e.invalidate(i,!1)}handleAsyncError(e,t){const r=this.findError(e.path,t);if(!r)return;const i=`${e.label} ${r.message}`;e.setValidationAsyncData(!1,i)}findError(e,t){return a.default.find(t,(({dataPath:t})=>{let r;return r=a.default.trimStart(t,"."),r=a.default.replace(r,"]",""),r=a.default.replace(r,"[","."),a.default.includes(r,e)}))}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!1,!0)}}t.default=e=>({class:o,config:e})},479:t=>{t.exports=e}},r={};return function e(i){var a=r[i];if(void 0!==a)return a.exports;var o=r[i]={exports:{}};return t[i].call(o.exports,o,o.exports,e),o.exports}(324)})()));
//# sourceMappingURL=MobxReactFormValidatorSVK.umd.min.js.map

@@ -109,5 +109,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

executeAsyncValidation(field) {
const data = field.validationAsyncData;
if (data.valid === false) {
field.invalidate(data.message, false, true);
if (field.validationAsyncData.valid === false) {
field.invalidate(field.validationAsyncData.message, false, true);
}

@@ -114,0 +113,0 @@ }

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("_")):"function"==typeof define&&define.amd?define(["_"],t):"object"==typeof exports?exports.MobxReactFormValidatorVJF=t(require("_")):e.MobxReactFormValidatorVJF=t(e._)}(self,(e=>(()=>{"use strict";var t={69:function(e,t,i){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VJF=void 0;const o=a(i(479));function r(e){return!!e&&"function"==typeof e.then&&("object"==typeof e||"function"==typeof e)}class n{constructor({config:e,state:t=null,promises:i=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=t,this.promises=i,this.config=e,this.extend=null==e?void 0:e.extend,this.validator=null==e?void 0:e.package,this.extendValidator()}extendValidator(){"function"==typeof this.extend&&this.extend({validator:this.validator,form:this.state.form})}validate(e){e.validators&&((Array.isArray(e.validators)?e.validators:[e.validators]).forEach((t=>this.collectData(t,e))),this.executeValidation(e))}collectData(e,t){const i=this.handleFunctionResult(e,t);if(r(i)){const e=i.then((([e,i])=>t.setValidationAsyncData(e,i))).then((()=>this.executeAsyncValidation(t)));this.promises.push(e)}else t.validationFunctionsData.unshift({valid:i[0],message:i[1]})}executeValidation(e){e.validationFunctionsData.forEach((({valid:t,message:i})=>{!1===t&&e.invalidate(i,!1)}))}executeAsyncValidation(e){const t=e.validationAsyncData;!1===t.valid&&e.invalidate(t.message,!1,!0)}handleFunctionResult(e,t){const i=e({validator:this.validator,form:this.state.form,field:t});return Array.isArray(i)?[i[0]||!1,i[1]||"Error"]:o.default.isBoolean(i)?[i,"Error"]:o.default.isString(i)?[!1,i]:r(i)?i:[!1,"Error"]}}t.VJF=n,t.default=e=>({class:n,config:e})},479:t=>{t.exports=e}},i={};return function e(a){var o=i[a];if(void 0!==o)return o.exports;var r=i[a]={exports:{}};return t[a].call(r.exports,r,r.exports,e),r.exports}(69)})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("_")):"function"==typeof define&&define.amd?define(["_"],t):"object"==typeof exports?exports.MobxReactFormValidatorVJF=t(require("_")):e.MobxReactFormValidatorVJF=t(e._)}(self,(e=>(()=>{"use strict";var t={69:function(e,t,i){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VJF=void 0;const o=a(i(479));function r(e){return!!e&&"function"==typeof e.then&&("object"==typeof e||"function"==typeof e)}class n{constructor({config:e,state:t=null,promises:i=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=t,this.promises=i,this.config=e,this.extend=null==e?void 0:e.extend,this.validator=null==e?void 0:e.package,this.extendValidator()}extendValidator(){"function"==typeof this.extend&&this.extend({validator:this.validator,form:this.state.form})}validate(e){e.validators&&((Array.isArray(e.validators)?e.validators:[e.validators]).forEach((t=>this.collectData(t,e))),this.executeValidation(e))}collectData(e,t){const i=this.handleFunctionResult(e,t);if(r(i)){const e=i.then((([e,i])=>t.setValidationAsyncData(e,i))).then((()=>this.executeAsyncValidation(t)));this.promises.push(e)}else t.validationFunctionsData.unshift({valid:i[0],message:i[1]})}executeValidation(e){e.validationFunctionsData.forEach((({valid:t,message:i})=>{!1===t&&e.invalidate(i,!1)}))}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!1,!0)}handleFunctionResult(e,t){const i=e({validator:this.validator,form:this.state.form,field:t});return Array.isArray(i)?[i[0]||!1,i[1]||"Error"]:o.default.isBoolean(i)?[i,"Error"]:o.default.isString(i)?[!1,i]:r(i)?i:[!1,"Error"]}}t.VJF=n,t.default=e=>({class:n,config:e})},479:t=>{t.exports=e}},i={};return function e(a){var o=i[a];if(void 0!==o)return o.exports;var r=i[a]={exports:{}};return t[a].call(r.exports,r,r.exports,e),r.exports}(69)})()));
//# sourceMappingURL=MobxReactFormValidatorVJF.umd.min.js.map

@@ -83,8 +83,8 @@ (function webpackUniversalModuleDefinition(root, factory) {

createValidationPromise(field) {
return new Promise((resolve) => this.validator
.reach(this.schema, field.path)
.label(field.label)
.validate(field.validatedValue, { strict: true })
.then(() => this.handleAsyncPasses(field, resolve))
.catch((error) => this.handleAsyncFails(field, resolve, error)));
return new Promise((resolve) => {
this.schema
.validateAt(field.path, this.state.form.values(), { strict: true })
.then(() => this.handleAsyncPasses(field, resolve))
.catch((error) => this.handleAsyncFails(field, resolve, error));
});
}

@@ -98,5 +98,11 @@ // Gestione dei successi della validazione asincrona

handleAsyncFails(field, resolve, error) {
field.setValidationAsyncData(false, error.errors[0]);
this.executeAsyncValidation(field);
resolve();
var _a, _b;
// Yup a volte restituisce errori senza path (es. array vuoti)
const isSameField = error.path === field.path || error.path === undefined;
if (isSameField) {
const message = (_a = error.message) === null || _a === void 0 ? void 0 : _a.replace((_b = error.path) !== null && _b !== void 0 ? _b : field.path, field.label);
field.setValidationAsyncData(false, message);
this.executeAsyncValidation(field);
}
resolve(undefined);
}

@@ -103,0 +109,0 @@ // Esecuzione della validazione asincrona

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MobxReactFormValidatorYUP=t():e.MobxReactFormValidatorYUP=t()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0});class a{constructor({config:e,state:t=null,promises:a=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=t,this.promises=a,this.extend=null==e?void 0:e.extend,this.validator=e.package,this.schema=e.schema(this.validator),this.extendValidator()}extendValidator(){"function"==typeof this.extend&&this.extend({validator:this.validator,form:this.state.form})}validate(e){const t=this.createValidationPromise(e);this.promises.push(t)}createValidationPromise(e){return new Promise((t=>this.validator.reach(this.schema,e.path).label(e.label).validate(e.validatedValue,{strict:!0}).then((()=>this.handleAsyncPasses(e,t))).catch((a=>this.handleAsyncFails(e,t,a)))))}handleAsyncPasses(e,t){e.setValidationAsyncData(!0),t()}handleAsyncFails(e,t,a){e.setValidationAsyncData(!1,a.errors[0]),this.executeAsyncValidation(e),t()}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!1,!0)}}t.default=e=>({class:a,config:e})})(),e})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MobxReactFormValidatorYUP=t():e.MobxReactFormValidatorYUP=t()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0});class a{constructor({config:e,state:t=null,promises:a=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=t,this.promises=a,this.extend=null==e?void 0:e.extend,this.validator=e.package,this.schema=e.schema(this.validator),this.extendValidator()}extendValidator(){"function"==typeof this.extend&&this.extend({validator:this.validator,form:this.state.form})}validate(e){const t=this.createValidationPromise(e);this.promises.push(t)}createValidationPromise(e){return new Promise((t=>{this.schema.validateAt(e.path,this.state.form.values(),{strict:!0}).then((()=>this.handleAsyncPasses(e,t))).catch((a=>this.handleAsyncFails(e,t,a)))}))}handleAsyncPasses(e,t){e.setValidationAsyncData(!0),t()}handleAsyncFails(e,t,a){var i,s;if(a.path===e.path||void 0===a.path){const t=null===(i=a.message)||void 0===i?void 0:i.replace(null!==(s=a.path)&&void 0!==s?s:e.path,e.label);e.setValidationAsyncData(!1,t),this.executeAsyncValidation(e)}t(void 0)}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!1,!0)}}t.default=e=>({class:a,config:e})})(),e})()));
//# sourceMappingURL=MobxReactFormValidatorYUP.umd.min.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet