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

mobx-react-form

Package Overview
Dependencies
Maintainers
1
Versions
249
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 6.2.3 to 6.3.0

lib/composer.d.ts

6

lib/Base.d.ts

@@ -73,3 +73,7 @@ import { ObservableMap } from "mobx";

*/
submit(o?: any, execHook?: boolean): Promise<any>;
submit(hooks?: any, { execOnSubmitHook, execValidationHooks, validate }?: {
execOnSubmitHook?: boolean;
execValidationHooks?: boolean;
validate?: boolean;
}): Promise<any>;
/**

@@ -76,0 +80,0 @@ Check Field Computed Values

30

lib/Base.js

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

writable: true,
value: (opt) => this.MOBXEvent(lodash_1.default.isFunction(opt)
value: (opt) => this.MOBXEvent((typeof opt === 'function')
? { type: "interceptor", call: opt }

@@ -135,3 +135,3 @@ : Object.assign({ type: "interceptor" }, opt))

writable: true,
value: (opt) => this.MOBXEvent(lodash_1.default.isFunction(opt)
value: (opt) => this.MOBXEvent((typeof opt === 'function')
? { type: "observer", call: opt }

@@ -173,3 +173,3 @@ : Object.assign({ type: "observer" }, opt))

e.preventDefault();
this.submit(o, false);
this.submit(o, { execOnSubmitHook: false });
})

@@ -354,7 +354,7 @@ });

*/
submit(o = {}, execHook = true) {
execHook && this.execHook(FieldProps_1.FieldPropsEnum.onSubmit, o);
submit(hooks = {}, { execOnSubmitHook = true, execValidationHooks = true, validate = true } = {}) {
execOnSubmitHook && this.execHook(FieldProps_1.FieldPropsEnum.onSubmit, hooks);
this.$submitting = true;
this.$submitted += 1;
if (!this.state.options.get(OptionsModel_1.OptionsEnum.validateOnSubmit, this)) {
if (!validate || !this.state.options.get(OptionsModel_1.OptionsEnum.validateOnSubmit, this)) {
return Promise

@@ -366,4 +366,4 @@ .resolve(this)

const exec = (isValid) => isValid
? this.execHook(ValidatorInterface_1.ValidationHooks.onSuccess, o)
: this.execHook(ValidatorInterface_1.ValidationHooks.onError, o);
? this.execHook(ValidatorInterface_1.ValidationHooks.onSuccess, hooks)
: this.execHook(ValidatorInterface_1.ValidationHooks.onError, hooks);
return (this.validate({

@@ -373,3 +373,3 @@ showErrors: this.state.options.get(OptionsModel_1.OptionsEnum.showErrorsOnSubmit, this),

.then(({ isValid }) => {
const handler = exec(isValid);
const handler = execValidationHooks ? exec(isValid) : undefined;
if (isValid)

@@ -431,3 +431,4 @@ return handler;

const $path = lodash_1.default.trimStart(`${path}.${$key}`, ".");
const $field = this.select($path, null, false);
const strictUpdate = this.state.options.get(OptionsModel_1.OptionsEnum.strictUpdate, this);
const $field = this.select($path, null, strictUpdate);
const $container = this.select(path, null, false) || this.state.form.select(this.path, null, false);

@@ -583,3 +584,3 @@ const applyInputConverterOnUpdate = this.state.options.get(OptionsModel_1.OptionsEnum.applyInputConverterOnUpdate, this);

const err = "You are updating a not existent field:";
const isStrict = this.state.options.get(OptionsModel_1.OptionsEnum.strictUpdate, this);
const isStrict = this.state.options.get(OptionsModel_1.OptionsEnum.strictSet, this);
if (lodash_1.default.isNil(data)) {

@@ -745,3 +746,5 @@ this.each((field) => field.$value = (0, parser_1.defaultValue)({

keys.shift();
let $fields = lodash_1.default.isNil(fields) ? this.fields.get(head) : fields.get(head);
let $fields = lodash_1.default.isNil(fields)
? this.fields.get(head)
: fields.get(head);
let stop = false;

@@ -759,4 +762,5 @@ lodash_1.default.each(keys, ($key) => {

});
if (isStrict)
if (isStrict && this.state.options.get(OptionsModel_1.OptionsEnum.strictSelect, this)) {
(0, utils_1.throwError)(path, $fields);
}
return $fields;

@@ -763,0 +767,0 @@ }

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

lodash_1.default.each(bindings, (val, key) => {
if (lodash_1.default.isFunction(val))
if ((typeof val === 'function'))
lodash_1.default.merge(this.templates, { [key]: val });

@@ -51,0 +51,0 @@ if (lodash_1.default.isPlainObject(val))

@@ -19,2 +19,16 @@ import Base from "./Base";

$output: ($: any) => any;
_value: Function;
_label: Function;
_placeholder: Function;
_disabled: Function;
_rules: Function;
_related: Function;
_deleted: Function;
_validatedWith: Function;
_validators: Function;
_bindings: Function;
_extra: Function;
_options: Function;
_autoFocus: Function;
_inputMode: Function;
$options: OptionsModel | undefined;

@@ -52,5 +66,6 @@ $value: any;

get checkValidationErrors(): boolean;
set value(newVal: any);
get actionRunning(): boolean;
get checked(): any;
get value(): any;
set value(newVal: any);
get initial(): any;

@@ -60,16 +75,16 @@ get default(): any;

set default(val: any);
get actionRunning(): boolean;
get ref(): any;
get extra(): any;
get ref(): any;
get autoFocus(): boolean;
get inputMode(): string;
get type(): string;
get label(): string;
get placeholder(): string;
get options(): OptionsModel;
get autoFocus(): any;
get inputMode(): any;
get type(): any;
get label(): any;
get placeholder(): any;
get options(): any;
get bindings(): any;
get related(): string[];
get disabled(): boolean;
get rules(): string[];
get validators(): any[];
get related(): any;
get disabled(): any;
get rules(): any;
get validators(): any;
get validatedWith(): any;
get validatedValue(): any;

@@ -76,0 +91,0 @@ get error(): string;

@@ -13,25 +13,54 @@ "use strict";

const FieldProps_1 = require("./models/FieldProps");
const applyFieldPropFunc = (instance, prop) => {
if (typeof prop !== 'function')
return prop;
return prop.apply(instance, [{
field: instance,
form: instance.state.form
}]);
};
const retrieveFieldPropFunc = (prop) => (typeof prop === 'function') ? prop : undefined;
const propGetter = (instance, prop) => (typeof instance[`_${prop}`] === 'function')
? instance[`_${prop}`].apply(instance, [{
form: instance.state.form,
field: instance,
}]) : instance[`$${prop}`];
const setupFieldProps = (instance, props, data) => Object.assign(instance, {
$label: props.$label || (data && data.label) || "",
$placeholder: props.$placeholder || (data && data.placeholder) || "",
$disabled: props.$disabled || (data && data.disabled) || false,
$rules: props.$rules || (data && data.rules) || null,
$related: props.$related || (data && data.related) || [],
$deleted: props.$deleted || (data && data.deleted) || false,
$validators: (0, mobx_1.toJS)(props.$validators || (data && data.validators) || null),
$validatedWith: props.$validatedWith || (data && data.validatedWith) || FieldProps_1.FieldPropsEnum.value,
$bindings: props.$bindings || (data && data.bindings) || FieldProps_1.FieldPropsEnum.default,
$observers: props.$observers || (data && data.observers) || null,
$interceptors: props.$interceptors || (data && data.interceptors) || null,
$extra: props.$extra || (data && data.extra) || null,
$options: props.$options || (data && data.options) || {},
$hooks: props.$hooks || (data && data.hooks) || {},
$handlers: props.$handlers || (data && data.handlers) || {},
$autoFocus: props.$autoFocus || (data && data.autoFocus) || false,
$inputMode: props.$inputMode || (data && data.inputMode) || undefined,
$ref: props.$ref || (data && data.ref) || undefined,
// retrieve functions
_label: retrieveFieldPropFunc(props.$label || (data === null || data === void 0 ? void 0 : data.label)),
_placeholder: retrieveFieldPropFunc(props.$placeholder || (data === null || data === void 0 ? void 0 : data.placeholder)),
_disabled: retrieveFieldPropFunc(props.$disabled || (data === null || data === void 0 ? void 0 : data.disabled)),
_rules: retrieveFieldPropFunc(props.$rules || (data === null || data === void 0 ? void 0 : data.rules)),
_related: retrieveFieldPropFunc(props.$related || (data === null || data === void 0 ? void 0 : data.related)),
_deleted: retrieveFieldPropFunc(props.$deleted || (data === null || data === void 0 ? void 0 : data.deleted)),
_validators: retrieveFieldPropFunc(props.$validators || (data === null || data === void 0 ? void 0 : data.validators)),
_validatedWith: retrieveFieldPropFunc(props.$validatedWith || (data === null || data === void 0 ? void 0 : data.validatedWith)),
_bindings: retrieveFieldPropFunc(props.$bindings || (data === null || data === void 0 ? void 0 : data.bindings)),
_extra: retrieveFieldPropFunc(props.$extra || (data === null || data === void 0 ? void 0 : data.extra)),
_options: retrieveFieldPropFunc(props.$options || (data === null || data === void 0 ? void 0 : data.options)),
_autoFocus: retrieveFieldPropFunc(props.$autoFocus || (data === null || data === void 0 ? void 0 : data.autoFocus)),
_inputMode: retrieveFieldPropFunc(props.$inputMode || (data === null || data === void 0 ? void 0 : data.inputMode)),
// apply functions or value
$label: applyFieldPropFunc(instance, props.$label || (data === null || data === void 0 ? void 0 : data.label) || ""),
$placeholder: applyFieldPropFunc(instance, props.$placeholder || (data === null || data === void 0 ? void 0 : data.placeholder) || ""),
$disabled: applyFieldPropFunc(instance, props.$disabled || (data === null || data === void 0 ? void 0 : data.disabled) || false),
$rules: applyFieldPropFunc(instance, props.$rules || (data === null || data === void 0 ? void 0 : data.rules) || null),
$related: applyFieldPropFunc(instance, props.$related || (data === null || data === void 0 ? void 0 : data.related) || []),
$deleted: applyFieldPropFunc(instance, props.$deleted || (data === null || data === void 0 ? void 0 : data.deleted) || false),
$validatedWith: applyFieldPropFunc(instance, props.$validatedWith || (data === null || data === void 0 ? void 0 : data.validatedWith) || FieldProps_1.FieldPropsEnum.value),
$bindings: applyFieldPropFunc(instance, props.$bindings || (data === null || data === void 0 ? void 0 : data.bindings) || FieldProps_1.FieldPropsEnum.default),
$extra: applyFieldPropFunc(instance, props.$extra || (data === null || data === void 0 ? void 0 : data.extra) || null),
$options: applyFieldPropFunc(instance, props.$options || (data === null || data === void 0 ? void 0 : data.options) || {}),
$autoFocus: applyFieldPropFunc(instance, props.$autoFocus || (data === null || data === void 0 ? void 0 : data.autoFocus) || false),
$inputMode: applyFieldPropFunc(instance, props.$inputMode || (data === null || data === void 0 ? void 0 : data.inputMode) || undefined),
$validators: applyFieldPropFunc(instance, props.$validators || (data === null || data === void 0 ? void 0 : data.validators) || null),
// other props
$hooks: props.$hooks || (data === null || data === void 0 ? void 0 : data.hooks) || {},
$handlers: props.$handlers || (data === null || data === void 0 ? void 0 : data.handlers) || {},
$observers: props.$observers || (data === null || data === void 0 ? void 0 : data.observers) || null,
$interceptors: props.$interceptors || (data === null || data === void 0 ? void 0 : data.interceptors) || null,
$ref: props.$ref || (data === null || data === void 0 ? void 0 : data.ref) || undefined,
});
const setupDefaultProp = (instance, data, props, update, { isEmptyArray, fallbackValueOption }) => (0, parser_1.parseInput)((val) => val, {
defaultValue: parser_1.defaultValue,
nullable: true,
isEmptyArray,

@@ -45,3 +74,3 @@ type: instance.type,

})
: data && data.default,
: data === null || data === void 0 ? void 0 : data.default,
separated: props.$default,

@@ -113,2 +142,86 @@ fallback: instance.$initial,

});
Object.defineProperty(this, "_value", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_label", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_placeholder", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_disabled", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_rules", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_related", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_deleted", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_validatedWith", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_validators", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_bindings", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_extra", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_options", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_autoFocus", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_inputMode", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "$options", {

@@ -475,8 +588,2 @@ enumerable: true,

}
get checked() {
return this.type === "checkbox" ? this.value : undefined;
}
get value() {
return this.getComputedProp(FieldProps_1.FieldPropsEnum.value);
}
set value(newVal) {

@@ -509,2 +616,13 @@ if (lodash_1.default.isString(newVal) && this.state.options.get(OptionsModel_1.OptionsEnum.autoTrimValue, this)) {

}
get actionRunning() {
return this.submitting || this.clearing || this.resetting;
}
get checked() {
return this.type === "checkbox" ? this.value : undefined;
}
get value() {
return (typeof this._value === 'function' && !this.hasNestedFields)
? propGetter(this, FieldProps_1.FieldPropsEnum.value)
: this.getComputedProp(FieldProps_1.FieldPropsEnum.value);
}
get initial() {

@@ -526,46 +644,46 @@ return this.$initial

}
get actionRunning() {
return this.submitting || this.clearing || this.resetting;
get ref() {
return propGetter(this, FieldProps_1.FieldPropsEnum.ref);
}
get extra() {
return this.$extra;
return propGetter(this, FieldProps_1.FieldPropsEnum.extra);
}
get ref() {
return this.$ref;
}
get autoFocus() {
return this.$autoFocus;
return propGetter(this, FieldProps_1.FieldPropsEnum.autoFocus);
}
get inputMode() {
return this.$inputMode;
return propGetter(this, FieldProps_1.FieldPropsEnum.inputMode);
}
get type() {
return (0, mobx_1.toJS)(this.$type);
return propGetter(this, FieldProps_1.FieldPropsEnum.type);
}
get label() {
return (0, mobx_1.toJS)(this.$label);
return propGetter(this, FieldProps_1.FieldPropsEnum.label);
}
get placeholder() {
return (0, mobx_1.toJS)(this.$placeholder);
return propGetter(this, FieldProps_1.FieldPropsEnum.placeholder);
}
get options() {
return (0, mobx_1.toJS)(this.$options);
return propGetter(this, FieldProps_1.FieldPropsEnum.options);
}
get bindings() {
return (0, mobx_1.toJS)(this.$bindings);
return propGetter(this, FieldProps_1.FieldPropsEnum.bindings);
}
get related() {
return (0, mobx_1.toJS)(this.$related);
return propGetter(this, FieldProps_1.FieldPropsEnum.related);
}
get disabled() {
return (0, mobx_1.toJS)(this.$disabled);
return propGetter(this, FieldProps_1.FieldPropsEnum.disabled);
}
get rules() {
return (0, mobx_1.toJS)(this.$rules);
return propGetter(this, FieldProps_1.FieldPropsEnum.rules);
}
get validators() {
return (0, mobx_1.toJS)(this.$validators);
return propGetter(this, FieldProps_1.FieldPropsEnum.validators);
}
get validatedWith() {
return propGetter(this, FieldProps_1.FieldPropsEnum.validatedWith);
}
get validatedValue() {
return (0, parser_1.parseCheckOutput)(this, this.$validatedWith);
return (0, parser_1.parseCheckOutput)(this, this.validatedWith);
}

@@ -639,3 +757,3 @@ get error() {

this.$output = (0, utils_1.$try)($output, output, this.$output);
this.$value = (0, parser_1.parseInput)(applyInputConverterOnInit ? this.$input : (val) => val, {
const value = (0, parser_1.parseInput)(applyInputConverterOnInit ? this.$input : (val) => val, {
fallbackValueOption,

@@ -648,5 +766,8 @@ isEmptyArray,

});
this._value = retrieveFieldPropFunc(value);
this.$value = (typeof this._value === 'function')
? applyFieldPropFunc(this, value)
: value;
this.$initial = (0, parser_1.parseInput)((val) => val, {
fallbackValueOption,
nullable: true,
isEmptyArray,

@@ -671,3 +792,3 @@ type: this.type,

this.$output = (0, utils_1.$try)($output, this.$output);
this.$value = (0, parser_1.parseInput)(applyInputConverterOnInit ? this.$input : (val) => val, {
const value = (0, parser_1.parseInput)(applyInputConverterOnInit ? this.$input : (val) => val, {
fallbackValueOption,

@@ -679,5 +800,8 @@ isEmptyArray,

});
this._value = retrieveFieldPropFunc(value);
this.$value = (typeof this._value === 'function')
? applyFieldPropFunc(this, value)
: value;
this.$initial = (0, parser_1.parseInput)((val) => val, {
fallbackValueOption,
nullable: true,
isEmptyArray,

@@ -684,0 +808,0 @@ type: this.type,

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

bindings,
}, (val, key) => lodash_1.default.isFunction(this[key])
}, (val, key) => (typeof this[key] === 'function')
? lodash_1.default.merge(val, this[key].apply(this, [this]))

@@ -71,0 +71,0 @@ : val);

@@ -24,4 +24,4 @@ import BaseInterface from "./BaseInterface";

showErrors(show: boolean): void;
clear(): void;
reset(): void;
clear(deep?: boolean, execHook?: boolean): void;
reset(deep?: boolean, execHook?: boolean): void;
makeField(data: FieldConstructor): FieldInterface;

@@ -28,0 +28,0 @@ }

@@ -25,4 +25,6 @@ export declare enum OptionsEnum {

validateOnReset = "validateOnReset",
strictSet = "strictSet",
strictUpdate = "strictUpdate",
strictDelete = "strictDelete",
strictSelect = "strictSelect",
softDelete = "softDelete",

@@ -70,4 +72,6 @@ retrieveOnlyDirtyFieldsValues = "retrieveOnlyDirtyFieldsValues",

[OptionsEnum.validateTrimmedValue]?: boolean;
[OptionsEnum.strictSet]?: boolean;
[OptionsEnum.strictUpdate]?: boolean;
[OptionsEnum.strictDelete]?: boolean;
[OptionsEnum.strictSelect]?: boolean;
[OptionsEnum.softDelete]?: boolean;

@@ -74,0 +78,0 @@ [OptionsEnum.retrieveOnlyDirtyFieldsValues]?: boolean;

@@ -29,4 +29,6 @@ "use strict";

OptionsEnum["validateOnReset"] = "validateOnReset";
OptionsEnum["strictSet"] = "strictSet";
OptionsEnum["strictUpdate"] = "strictUpdate";
OptionsEnum["strictDelete"] = "strictDelete";
OptionsEnum["strictSelect"] = "strictSelect";
OptionsEnum["softDelete"] = "softDelete";

@@ -33,0 +35,0 @@ OptionsEnum["retrieveOnlyDirtyFieldsValues"] = "retrieveOnlyDirtyFieldsValues";

export default interface SharedActionsInterface {
validate(opt?: any, obj?: any): Promise<any>;
submit(options?: any): Promise<any>;
submit(hooks: any, opt: {
execOnSubmitHook: boolean;
execValidationHooks: boolean;
validate: boolean;
}): Promise<any>;
check(prop: string, deep?: boolean): boolean;

@@ -5,0 +9,0 @@ deepCheck(type: string, prop: string, fields: any): any;

@@ -38,4 +38,6 @@ "use strict";

validatePristineFields: true,
strictSet: false,
strictUpdate: false,
strictDelete: true,
strictSelect: true,
softDelete: false,

@@ -42,0 +44,0 @@ retrieveOnlyDirtyFieldsValues: false,

@@ -1,5 +0,5 @@

declare const defaultValue: ({ type, value, nullable, isEmptyArray, fallbackValueOption, }: any) => null | false | 0 | [
declare const defaultValue: ({ type, value, isEmptyArray, fallbackValueOption, }: any) => null | false | 0 | [
] | "";
declare const parsePath: (path: string) => string;
declare const parseInput: (input: any, { fallbackValueOption, type, isEmptyArray, nullable, separated, unified, fallback }: any) => any;
declare const parseInput: (input: any, { fallbackValueOption, type, isEmptyArray, separated, unified, fallback }: any) => any;
declare const parseArrayProp: (val: any, prop: string, removeNullishValuesInArrays: boolean) => any;

@@ -6,0 +6,0 @@ declare const parseCheckArray: (field: any, value: any, prop: string, removeNullishValuesInArrays: boolean) => any;

@@ -10,11 +10,7 @@ "use strict";

const utils_1 = require("./utils");
const defaultValue = ({ type = undefined, value = undefined, nullable = false, isEmptyArray = false, fallbackValueOption = "", }) => {
if (type === "file")
return "";
if (type === "nullable")
const defaultValue = ({ type = undefined, value = undefined, isEmptyArray = false, fallbackValueOption = "", }) => {
if (lodash_1.default.isArray(value) || isEmptyArray)
return [];
if (lodash_1.default.isDate(value) || type === "date" || type === "datetime-local")
return null;
if (type === "datetime-local")
return null;
if (lodash_1.default.isDate(value) || type === "date")
return null;
if (lodash_1.default.isNumber(value) || type === "number")

@@ -24,10 +20,4 @@ return 0;

return false;
if (lodash_1.default.isString(value))
if (lodash_1.default.isString(value) || type === "file")
return "";
if (lodash_1.default.isArray(value))
return [];
if (nullable)
return null;
if (isEmptyArray)
return [];
return fallbackValueOption;

@@ -43,7 +33,6 @@ };

exports.parsePath = parsePath;
const parseInput = (input, { fallbackValueOption = "", type, isEmptyArray, nullable, separated, unified, fallback }) => input((0, utils_1.$try)(separated, unified, fallback, defaultValue({
const parseInput = (input, { fallbackValueOption = "", type, isEmptyArray, separated, unified, fallback }) => input((0, utils_1.$try)(separated, unified, fallback, defaultValue({
fallbackValueOption,
type,
isEmptyArray,
nullable,
})));

@@ -53,5 +42,7 @@ exports.parseInput = parseInput;

const values = lodash_1.default.values(val);
const isValProp = (prop === FieldProps_1.FieldPropsEnum.value
|| prop === FieldProps_1.FieldPropsEnum.initial
|| prop === FieldProps_1.FieldPropsEnum.default);
const isValProp = [
FieldProps_1.FieldPropsEnum.value,
FieldProps_1.FieldPropsEnum.initial,
FieldProps_1.FieldPropsEnum.default,
].includes(prop);
if (removeNullishValuesInArrays && isValProp) {

@@ -193,3 +184,3 @@ return lodash_1.default.without(values, ...[null, undefined, ""]);

const handleFieldsPropsFallback = (fields, initial, fallback) => {
if (!lodash_1.default.has(initial, "values"))
if (!lodash_1.default.has(initial, FieldProps_1.SeparatedPropsMode.values))
return fields;

@@ -196,0 +187,0 @@ // if the 'values' object is passed in constructor

@@ -19,3 +19,2 @@ "use strict";

FieldProps_1.FieldPropsEnum.handlers,
FieldProps_1.FieldPropsEnum.error,
FieldProps_1.FieldPropsEnum.deleted,

@@ -40,2 +39,3 @@ FieldProps_1.FieldPropsEnum.disabled,

computed: [
FieldProps_1.FieldPropsEnum.error,
FieldProps_1.FieldPropsEnum.hasError,

@@ -42,0 +42,0 @@ FieldProps_1.FieldPropsEnum.isValid,

@@ -121,5 +121,5 @@ "use strict";

...props_1.props.editable,
...props_1.props.handlers,
...props_1.props.validation,
...props_1.props.functions,
...props_1.props.handlers,
]) || strictProps);

@@ -126,0 +126,0 @@ exports.allowNested = allowNested;

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

const path = (0, utils_1.$try)(opt.path, opt);
const instance = (0, utils_1.$try)(opt.field, this.form.select(path, null, null), this.form);
const instance = (0, utils_1.$try)(opt.field, this.form.select(path, null, false), this.form);
const related = (0, utils_1.$try)(opt.related, obj.related, true);

@@ -72,0 +72,0 @@ const showErrors = (0, utils_1.$try)(opt.showErrors, obj.showErrors, false);

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

// extend using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -62,0 +62,0 @@ validator: this.validator,

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

// extend ajv using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -83,0 +83,0 @@ form: this.state.form,

@@ -8,3 +8,2 @@ "use strict";

const lodash_1 = __importDefault(require("lodash"));
const mobx_1 = require("mobx");
const isPromise = (obj) => !!obj &&

@@ -63,3 +62,3 @@ typeof obj.then === "function" &&

// extend using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -76,3 +75,3 @@ validator: this.validator,

// get validators from validate property
const $fn = (0, mobx_1.toJS)(field.validators);
const $fn = field.validators;
// map only if is an array of validator functions

@@ -82,6 +81,6 @@ if (lodash_1.default.isArray($fn)) {

}
// it's just one function
if (lodash_1.default.isFunction($fn)) {
this.collectData($fn, field);
}
// it's just one function // DEPRECATED
// if (typeof $fn === 'function') {
// this.collectData($fn, field);
// }
// execute the validation function

@@ -88,0 +87,0 @@ this.executeValidation(field);

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
/**

@@ -66,3 +62,3 @@ YUP - Dead simple Object schema validation

// extend using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -69,0 +65,0 @@ validator: this.validator,

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

@@ -6,0 +6,0 @@ "description": "Automagically manage React forms state and automatic validation with MobX.",

@@ -28,10 +28,12 @@

- Extensibles Validation Plugins.
- Extensibles [Validation Plugins](https://foxhound87.github.io/mobx-react-form/docs/validation/plugins.html).
- Sync & Async Validation (w/ Promises & automatic errors).
- Nested Fields (w/ Serialization & Validation).
- Nested Forms (w/ Nested Submission & Validation Hooks).
- Event Hooks, Event Handlers & Validation Hooks
- Observers & Interceptors
- Bindings for custom Components.
- [Event Hooks](https://foxhound87.github.io/mobx-react-form/docs/events/event-hooks.html), [Event Handlers](https://foxhound87.github.io/mobx-react-form/docs/events/event-handlers.html) & [Validation Hooks](https://foxhound87.github.io/mobx-react-form/docs/events/validation-hooks.html)
- Functional [Computed Field Props](https://foxhound87.github.io/mobx-react-form/docs/extra/computed-props.html)
- Field Props [Observers & Interceptors](https://foxhound87.github.io/mobx-react-form/docs/extra/mobx-events.html)
- Field [Props Bindings](https://foxhound87.github.io/mobx-react-form/docs/bindings) for custom Components.
- Support for Material UI, React Widgets, React Select & more.
- [Forms Composer](https://foxhound87.github.io/mobx-react-form/docs/extra/composer.html): to handle multi-forms submit, validations and other actions
- Dedicated [DevTools](https://github.com/foxhound87/mobx-react-form-devtools) Package.

@@ -109,3 +111,3 @@

> See more on the docs about the [Validation Hooks](https://foxhound87.github.io/mobx-react-form/docs/events/validation-hooks.html)
> See more on the docs about the [Validation Hooks](https://foxhound87.github.io/mobx-react-form/docs/events/validation-hooks.html) and the [Event Hooks](https://foxhound87.github.io/mobx-react-form/docs/events/event-hooks.html)

@@ -136,3 +138,3 @@ #### Initialize the Form

<form onSubmit={myForm.onSubmit}>
<label for={myForm.$('email').id}>
<label htmlFor={myForm.$('email').id}>
{myForm.$('email').label}

@@ -139,0 +141,0 @@ </label>

@@ -164,3 +164,3 @@ import {

this.MOBXEvent(
_.isFunction(opt)
(typeof opt === 'function')
? { type: "interceptor", call: opt }

@@ -175,3 +175,3 @@ : { type: "interceptor", ...opt }

this.MOBXEvent(
_.isFunction(opt)
(typeof opt === 'function')
? { type: "observer", call: opt }

@@ -205,3 +205,3 @@ : { type: "observer", ...opt }

e.preventDefault();
this.submit(o, false);
this.submit(o, { execOnSubmitHook: false });
});

@@ -335,8 +335,12 @@

*/
submit(o: any = {}, execHook: boolean = true): Promise<any> {
execHook && this.execHook(FieldPropsEnum.onSubmit, o);
submit(hooks: any = {}, {
execOnSubmitHook = true,
execValidationHooks = true,
validate = true
} = {}): Promise<any> {
execOnSubmitHook && this.execHook(FieldPropsEnum.onSubmit, hooks);
this.$submitting = true;
this.$submitted += 1;
if (!this.state.options.get(OptionsEnum.validateOnSubmit, this)) {
if (!validate || !this.state.options.get(OptionsEnum.validateOnSubmit, this)) {
return Promise

@@ -349,4 +353,4 @@ .resolve(this)

const exec = (isValid: boolean) => isValid
? this.execHook(ValidationHooks.onSuccess, o)
: this.execHook(ValidationHooks.onError, o);
? this.execHook(ValidationHooks.onSuccess, hooks)
: this.execHook(ValidationHooks.onError, hooks);

@@ -358,3 +362,3 @@ return (

.then(({ isValid }: any) => {
const handler = exec(isValid);
const handler = execValidationHooks ? exec(isValid) : undefined;
if (isValid) return handler;

@@ -433,3 +437,5 @@ const $err = this.state.options.get(OptionsEnum.defaultGenericError, this);

const $path = _.trimStart(`${path}.${$key}`, ".");
const $field = this.select($path, null, false);
const strictUpdate = this.state.options.get(OptionsEnum.strictUpdate, this);
const $field = this.select($path, null, strictUpdate);
const $container = this.select(path, null, false) || this.state.form.select(this.path, null, false);

@@ -614,3 +620,3 @@ const applyInputConverterOnUpdate = this.state.options.get(OptionsEnum.applyInputConverterOnUpdate, this);

const err = "You are updating a not existent field:";
const isStrict = this.state.options.get(OptionsEnum.strictUpdate, this);
const isStrict = this.state.options.get(OptionsEnum.strictSet, this);

@@ -802,3 +808,2 @@ if (_.isNil(data)) {

const $path = parsePath(path);
const keys = _.split($path, ".");

@@ -809,3 +814,5 @@ const head = _.head(keys);

let $fields = _.isNil(fields) ? this.fields.get(head) : fields.get(head);
let $fields = _.isNil(fields)
? this.fields.get(head)
: fields.get(head);

@@ -823,3 +830,5 @@ let stop = false;

if (isStrict) throwError(path, $fields);
if (isStrict && this.state.options.get(OptionsEnum.strictSelect, this)) {
throwError(path, $fields);
}

@@ -826,0 +835,0 @@ return $fields;

@@ -36,3 +36,3 @@ import _ from "lodash";

_.each(bindings, (val, key) => {
if (_.isFunction(val)) _.merge(this.templates, { [key]: val });
if ((typeof val === 'function')) _.merge(this.templates, { [key]: val });
if (_.isPlainObject(val)) _.merge(this.rewriters, { [key]: val });

@@ -39,0 +39,0 @@ });

@@ -27,22 +27,57 @@ import {

const applyFieldPropFunc = (instance: FieldInterface, prop: any): any => {
if (typeof prop !== 'function') return prop;
return prop.apply(instance, [{
field: instance,
form: instance.state.form
}])
};
const retrieveFieldPropFunc = (prop: any): Function | any | undefined =>
(typeof prop === 'function') ? prop : undefined;
const propGetter = (instance: FieldInterface, prop: FieldPropsEnum): any =>
(typeof instance[`_${prop}`] === 'function')
? instance[`_${prop}`].apply(instance, [{
form: instance.state.form,
field: instance,
}]) : instance[`$${prop}`];
const setupFieldProps = (instance: FieldInterface, props: any, data: any) =>
Object.assign(instance, {
$label: props.$label || (data && data.label) || "",
$placeholder: props.$placeholder || (data && data.placeholder) || "",
$disabled: props.$disabled || (data && data.disabled) || false,
$rules: props.$rules || (data && data.rules) || null,
$related: props.$related || (data && data.related) || [],
$deleted: props.$deleted || (data && data.deleted) || false,
$validators: toJS(props.$validators || (data && data.validators) || null),
$validatedWith: props.$validatedWith || (data && data.validatedWith) || FieldPropsEnum.value,
$bindings: props.$bindings || (data && data.bindings) || FieldPropsEnum.default,
$observers: props.$observers || (data && data.observers) || null,
$interceptors: props.$interceptors || (data && data.interceptors) || null,
$extra: props.$extra || (data && data.extra) || null,
$options: props.$options || (data && data.options) || {},
$hooks: props.$hooks || (data && data.hooks) || {},
$handlers: props.$handlers || (data && data.handlers) || {},
$autoFocus: props.$autoFocus || (data && data.autoFocus) || false,
$inputMode: props.$inputMode || (data && data.inputMode) || undefined,
$ref: props.$ref || (data && data.ref) || undefined,
// retrieve functions
_label: retrieveFieldPropFunc(props.$label || data?.label),
_placeholder: retrieveFieldPropFunc(props.$placeholder || data?.placeholder),
_disabled: retrieveFieldPropFunc(props.$disabled || data?.disabled),
_rules: retrieveFieldPropFunc(props.$rules || data?.rules),
_related: retrieveFieldPropFunc(props.$related || data?.related),
_deleted: retrieveFieldPropFunc(props.$deleted || data?.deleted),
_validators: retrieveFieldPropFunc(props.$validators || data?.validators),
_validatedWith: retrieveFieldPropFunc(props.$validatedWith || data?.validatedWith),
_bindings: retrieveFieldPropFunc(props.$bindings || data?.bindings),
_extra: retrieveFieldPropFunc(props.$extra || data?.extra),
_options: retrieveFieldPropFunc(props.$options || data?.options),
_autoFocus: retrieveFieldPropFunc(props.$autoFocus || data?.autoFocus),
_inputMode: retrieveFieldPropFunc(props.$inputMode || data?.inputMode),
// apply functions or value
$label: applyFieldPropFunc(instance, props.$label || data?.label || ""),
$placeholder: applyFieldPropFunc(instance, props.$placeholder || data?.placeholder || ""),
$disabled: applyFieldPropFunc(instance, props.$disabled || data?.disabled || false),
$rules: applyFieldPropFunc(instance, props.$rules || data?.rules || null),
$related: applyFieldPropFunc(instance, props.$related || data?.related || []),
$deleted: applyFieldPropFunc(instance, props.$deleted || data?.deleted || false),
$validatedWith: applyFieldPropFunc(instance, props.$validatedWith || data?.validatedWith || FieldPropsEnum.value),
$bindings: applyFieldPropFunc(instance, props.$bindings || data?.bindings || FieldPropsEnum.default),
$extra: applyFieldPropFunc(instance, props.$extra || data?.extra || null),
$options: applyFieldPropFunc(instance, props.$options || data?.options || {}),
$autoFocus: applyFieldPropFunc(instance, props.$autoFocus || data?.autoFocus || false),
$inputMode: applyFieldPropFunc(instance, props.$inputMode || data?.inputMode || undefined),
$validators: applyFieldPropFunc(instance, props.$validators || data?.validators || null),
// other props
$hooks: props.$hooks || data?.hooks || {},
$handlers: props.$handlers || data?.handlers || {},
$observers: props.$observers || data?.observers || null,
$interceptors: props.$interceptors || data?.interceptors || null,
$ref: props.$ref || data?.ref || undefined,
});

@@ -60,3 +95,2 @@

defaultValue,
nullable: true,
isEmptyArray,

@@ -70,3 +104,3 @@ type: instance.type,

})
: data && data.default,
: data?.default,
separated: props.$default,

@@ -96,2 +130,17 @@ fallback: instance.$initial,

_value: Function;
_label: Function;
_placeholder: Function;
_disabled: Function;
_rules: Function;
_related: Function;
_deleted: Function;
_validatedWith: Function;
_validators: Function;
_bindings: Function;
_extra: Function;
_options: Function;
_autoFocus: Function;
_inputMode: Function;
$options: OptionsModel | undefined;

@@ -251,10 +300,2 @@ $value: any;

get checked() {
return this.type === "checkbox" ? this.value : undefined;
}
get value() {
return this.getComputedProp(FieldPropsEnum.value);
}
set value(newVal) {

@@ -287,2 +328,16 @@ if (_.isString(newVal) && this.state.options.get(OptionsEnum.autoTrimValue, this)) {

get actionRunning() {
return this.submitting || this.clearing || this.resetting;
}
get checked() {
return this.type === "checkbox" ? this.value : undefined;
}
get value() {
return (typeof this._value === 'function' && !this.hasNestedFields)
? propGetter(this, FieldPropsEnum.value)
: this.getComputedProp(FieldPropsEnum.value);
}
get initial() {

@@ -308,60 +363,60 @@ return this.$initial

get actionRunning() {
return this.submitting || this.clearing || this.resetting;
get ref() {
return propGetter(this, FieldPropsEnum.ref)
}
get extra() {
return this.$extra;
return propGetter(this, FieldPropsEnum.extra)
}
get ref() {
return this.$ref;
}
get autoFocus() {
return this.$autoFocus;
return propGetter(this, FieldPropsEnum.autoFocus)
}
get inputMode() {
return this.$inputMode;
return propGetter(this, FieldPropsEnum.inputMode)
}
get type() {
return toJS(this.$type);
return propGetter(this, FieldPropsEnum.type)
}
get label() {
return toJS(this.$label);
return propGetter(this, FieldPropsEnum.label)
}
get placeholder() {
return toJS(this.$placeholder);
return propGetter(this, FieldPropsEnum.placeholder)
}
get options() {
return toJS(this.$options);
return propGetter(this, FieldPropsEnum.options)
}
get bindings() {
return toJS(this.$bindings);
return propGetter(this, FieldPropsEnum.bindings)
}
get related() {
return toJS(this.$related);
return propGetter(this, FieldPropsEnum.related)
}
get disabled() {
return toJS(this.$disabled);
return propGetter(this, FieldPropsEnum.disabled)
}
get rules() {
return toJS(this.$rules);
return propGetter(this, FieldPropsEnum.rules)
}
get validators() {
return toJS(this.$validators);
return propGetter(this, FieldPropsEnum.validators)
}
get validatedWith() {
return propGetter(this, FieldPropsEnum.validatedWith)
}
get validatedValue() {
return parseCheckOutput(this, this.$validatedWith as string);
return parseCheckOutput(this, this.validatedWith as string);
}

@@ -448,3 +503,8 @@

? this.onDrop(...args)
: this.execHandler(FieldPropsEnum.onChange, args, this.sync, FieldPropsEnum.onSync);
: this.execHandler(
FieldPropsEnum.onChange,
args,
this.sync,
FieldPropsEnum.onSync
);

@@ -454,3 +514,7 @@ onChange = this.onSync;

onToggle = (...args: any) =>
this.execHandler(FieldPropsEnum.onToggle, args, this.sync);
this.execHandler(
FieldPropsEnum.onToggle,
args,
this.sync
);

@@ -539,3 +603,3 @@ onBlur = (...args: any) =>

this.$value = parseInput(applyInputConverterOnInit ? this.$input : (val) => val, {
const value = parseInput(applyInputConverterOnInit ? this.$input : (val) => val, {
fallbackValueOption,

@@ -549,5 +613,9 @@ isEmptyArray,

this._value = retrieveFieldPropFunc(value)
this.$value = (typeof this._value === 'function')
? applyFieldPropFunc(this, value)
: value;
this.$initial = parseInput((val) => val, {
fallbackValueOption,
nullable: true,
isEmptyArray,

@@ -576,3 +644,3 @@ type: this.type,

this.$value = parseInput(applyInputConverterOnInit ? this.$input : (val) => val, {
const value = parseInput(applyInputConverterOnInit ? this.$input : (val) => val, {
fallbackValueOption,

@@ -585,5 +653,9 @@ isEmptyArray,

this._value = retrieveFieldPropFunc(value)
this.$value = (typeof this._value === 'function')
? applyFieldPropFunc(this, value)
: value;
this.$initial = parseInput((val) => val, {
fallbackValueOption,
nullable: true,
isEmptyArray,

@@ -590,0 +662,0 @@ type: this.type,

@@ -65,3 +65,3 @@ import { action, computed, observable, makeObservable, autorun } from "mobx";

(val, key) =>
_.isFunction((this as any)[key])
(typeof (this as any)[key] === 'function')
? _.merge(val, (this as any)[key].apply(this, [this]))

@@ -109,3 +109,2 @@ : val

this.each(($field: any) => (data[$field.path] = $field.validatedValue));
return data;

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

@@ -27,4 +27,4 @@ import BaseInterface from "./BaseInterface";

showErrors(show: boolean): void;
clear(): void;
reset(): void;
clear(deep?: boolean, execHook?: boolean): void;
reset(deep?: boolean, execHook?: boolean): void;

@@ -31,0 +31,0 @@ makeField(data: FieldConstructor): FieldInterface;

@@ -25,4 +25,6 @@ export enum OptionsEnum {

validateOnReset = 'validateOnReset',
strictSet = 'strictSet',
strictUpdate = 'strictUpdate',
strictDelete = 'strictDelete',
strictSelect = 'strictSelect',
softDelete = 'softDelete',

@@ -72,4 +74,6 @@ retrieveOnlyDirtyFieldsValues = 'retrieveOnlyDirtyFieldsValues',

[OptionsEnum.validateTrimmedValue]?: boolean;
[OptionsEnum.strictSet]?: boolean;
[OptionsEnum.strictUpdate]?: boolean;
[OptionsEnum.strictDelete]?: boolean;
[OptionsEnum.strictSelect]?: boolean;
[OptionsEnum.softDelete]?: boolean;

@@ -76,0 +80,0 @@ [OptionsEnum.retrieveOnlyDirtyFieldsValues]?: boolean;

export default interface SharedActionsInterface {
validate(opt?: any, obj?: any): Promise<any>;
submit(options?: any): Promise<any>;
submit(hooks: any, opt: { execOnSubmitHook: boolean, execValidationHooks: boolean, validate: boolean }): Promise<any>;
check(prop: string, deep?: boolean): boolean;

@@ -5,0 +5,0 @@ deepCheck(type: string, prop: string, fields: any): any;

@@ -41,4 +41,6 @@ import {

validatePristineFields: true,
strictSet: false,
strictUpdate: false,
strictDelete: true,
strictSelect: true,
softDelete: false,

@@ -45,0 +47,0 @@ retrieveOnlyDirtyFieldsValues: false,

import _ from "lodash";
import { FieldPropsEnum } from "./models/FieldProps";
import { FieldPropsEnum, SeparatedPropsMode } from "./models/FieldProps";
import {

@@ -16,16 +16,10 @@ $try,

value = undefined,
nullable = false,
isEmptyArray = false,
fallbackValueOption = "",
}: any): null | false | 0 | [] | "" => {
if (type === "file") return "";
if (type === "nullable") return null;
if (type === "datetime-local") return null;
if (_.isDate(value) || type === "date") return null;
if (_.isArray(value) || isEmptyArray) return [];
if (_.isDate(value) || type === "date" || type === "datetime-local") return null;
if (_.isNumber(value) || type === "number") return 0;
if (_.isBoolean(value) || type === "checkbox") return false;
if (_.isString(value)) return "";
if (_.isArray(value)) return [];
if (nullable) return null;
if (isEmptyArray) return [];
if (_.isString(value) || type === "file") return "";
return fallbackValueOption;

@@ -43,3 +37,3 @@ };

input: any,
{ fallbackValueOption = "", type, isEmptyArray, nullable, separated, unified, fallback }: any
{ fallbackValueOption = "", type, isEmptyArray, separated, unified, fallback }: any
) =>

@@ -55,3 +49,2 @@ input(

isEmptyArray,
nullable,
})

@@ -63,6 +56,7 @@ )

const values = _.values(val);
const isValProp: boolean =
(prop === FieldPropsEnum.value
|| prop === FieldPropsEnum.initial
|| prop === FieldPropsEnum.default);
const isValProp: boolean = ([
FieldPropsEnum.value,
FieldPropsEnum.initial,
FieldPropsEnum.default,
] as string[]).includes(prop)

@@ -235,3 +229,3 @@ if (removeNullishValuesInArrays && isValProp) {

) => {
if (!_.has(initial, "values")) return fields;
if (!_.has(initial, SeparatedPropsMode.values)) return fields;
// if the 'values' object is passed in constructor

@@ -238,0 +232,0 @@ // then update the fields definitions

@@ -29,3 +29,2 @@ import { FieldPropsEnum, FieldPropsOccurrence, SeparatedPropsMode } from "./models/FieldProps";

FieldPropsEnum.handlers,
FieldPropsEnum.error,
FieldPropsEnum.deleted,

@@ -50,2 +49,3 @@ FieldPropsEnum.disabled,

computed: [
FieldPropsEnum.error,
FieldPropsEnum.hasError,

@@ -52,0 +52,0 @@ FieldPropsEnum.isValid,

@@ -128,5 +128,5 @@ import _ from "lodash";

...props.editable,
...props.handlers,
...props.validation,
...props.functions,
...props.handlers,
]) || strictProps);

@@ -133,0 +133,0 @@

@@ -59,3 +59,3 @@ import { action, observable, makeObservable } from "mobx";

const path = $try(opt.path, opt);
const instance = $try(opt.field, this.form.select(path, null, null), this.form);
const instance = $try(opt.field, this.form.select(path, null, false), this.form);
const related = $try(opt.related, obj.related, true);

@@ -62,0 +62,0 @@ const showErrors = $try(opt.showErrors, obj.showErrors, false);

@@ -43,3 +43,3 @@ import _ from "lodash";

// extend using "extend" callback
if (_.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -46,0 +46,0 @@ validator: this.validator,

@@ -64,3 +64,3 @@ import _ from "lodash";

// extend ajv using "extend" callback
if (_.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -67,0 +67,0 @@ form: this.state.form,

@@ -48,3 +48,3 @@ import {

// extend using "extend" callback
if (_.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -61,3 +61,3 @@ validator: this.validator,

// get validators from validate property
const $fn = toJS(field.validators);
const $fn = field.validators;
// map only if is an array of validator functions

@@ -67,6 +67,6 @@ if (_.isArray($fn)) {

}
// it's just one function
if (_.isFunction($fn)) {
this.collectData($fn, field);
}
// it's just one function // DEPRECATED
// if (typeof $fn === 'function') {
// this.collectData($fn, field);
// }
// execute the validation function

@@ -73,0 +73,0 @@ this.executeValidation(field);

@@ -48,3 +48,3 @@ import {

// extend using "extend" callback
if (_.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -51,0 +51,0 @@ validator: this.validator,

@@ -79,3 +79,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

// extend using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -82,0 +82,0 @@ validator: this.validator,

@@ -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.MobxReactFormValidatorDVR=t(require("_")):e.MobxReactFormValidatorDVR=t(e._)}(self,(e=>(()=>{"use strict";var t={823:function(e,t,a){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DVR=void 0;const i=s(a(479));class l{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:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=a,this.extend=e.extend,this.validator=e.package||e,this.extendValidator()}extendValidator(){i.default.isFunction(this.extend)&&this.extend({validator:this.validator,form:this.state.form})}validate(e){const t=this.state.form.validatedValues;this.validateFieldAsync(e,t),this.validateFieldSync(e,t)}makeLabels(e,t){const a={[t.path]:t.label};i.default.forIn(e.rules[t.path],(e=>{if("string"==typeof e.value&&e.name.match(/^(required_|same|different)/))i.default.forIn(e.value.split(","),((t,s)=>{if(!e.name.match(/^required_(if|unless)/)||s%2==0){const e=this.state.form.$(t);e&&e.path&&e.label&&(a[e.path]=e.label)}}));else if("string"==typeof e.value&&e.name.match(/^(before|after)/)){const t=this.state.form.$(e.value);t&&t.path&&t.label&&(a[t.path]=t.label)}})),e.setAttributeNames(a)}validateFieldSync(e,t){const a=this.rules(e.rules,"sync");if(i.default.isEmpty(a[0]))return;const s={[e.path]:a},l=new this.validator(t,s);this.makeLabels(l,e),l.passes()||e.invalidate(i.default.first(l.errors.get(e.path)))}validateFieldAsync(e,t){const a=this.rules(e.rules,"async");if(i.default.isEmpty(a[0]))return;const s={[e.path]:a},l=new this.validator(t,s);this.makeLabels(l,e);const r=new Promise((t=>l.checkAsync((()=>this.handleAsyncPasses(e,t)),(()=>this.handleAsyncFails(e,l,t)))));this.promises.push(r)}handleAsyncPasses(e,t){e.setValidationAsyncData(!0),e.showAsyncErrors(),t()}handleAsyncFails(e,t,a){e.setValidationAsyncData(!1,i.default.first(t.errors.get(e.path))),this.executeAsyncValidation(e),e.showAsyncErrors(),a()}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!0)}rules(e,t){const a=i.default.isString(e)?i.default.split(e,"|"):e,s=new this.validator;return i.default.filter(a,(e=>"async"===t?s.getRule(i.default.split(e,":")[0]).async:!s.getRule(i.default.split(e,":")[0]).async))}}t.DVR=l,t.default=e=>({class:l,config:e})},479:t=>{t.exports=e}},a={};return function e(s){var i=a[s];if(void 0!==i)return i.exports;var l=a[s]={exports:{}};return t[s].call(l.exports,l,l.exports,e),l.exports}(823)})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("_")):"function"==typeof define&&define.amd?define(["_"],t):"object"==typeof exports?exports.MobxReactFormValidatorDVR=t(require("_")):e.MobxReactFormValidatorDVR=t(e._)}(self,(e=>(()=>{"use strict";var t={823:function(e,t,a){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DVR=void 0;const i=s(a(479));class l{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:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=a,this.extend=e.extend,this.validator=e.package||e,this.extendValidator()}extendValidator(){"function"==typeof this.extend&&this.extend({validator:this.validator,form:this.state.form})}validate(e){const t=this.state.form.validatedValues;this.validateFieldAsync(e,t),this.validateFieldSync(e,t)}makeLabels(e,t){const a={[t.path]:t.label};i.default.forIn(e.rules[t.path],(e=>{if("string"==typeof e.value&&e.name.match(/^(required_|same|different)/))i.default.forIn(e.value.split(","),((t,s)=>{if(!e.name.match(/^required_(if|unless)/)||s%2==0){const e=this.state.form.$(t);e&&e.path&&e.label&&(a[e.path]=e.label)}}));else if("string"==typeof e.value&&e.name.match(/^(before|after)/)){const t=this.state.form.$(e.value);t&&t.path&&t.label&&(a[t.path]=t.label)}})),e.setAttributeNames(a)}validateFieldSync(e,t){const a=this.rules(e.rules,"sync");if(i.default.isEmpty(a[0]))return;const s={[e.path]:a},l=new this.validator(t,s);this.makeLabels(l,e),l.passes()||e.invalidate(i.default.first(l.errors.get(e.path)))}validateFieldAsync(e,t){const a=this.rules(e.rules,"async");if(i.default.isEmpty(a[0]))return;const s={[e.path]:a},l=new this.validator(t,s);this.makeLabels(l,e);const r=new Promise((t=>l.checkAsync((()=>this.handleAsyncPasses(e,t)),(()=>this.handleAsyncFails(e,l,t)))));this.promises.push(r)}handleAsyncPasses(e,t){e.setValidationAsyncData(!0),e.showAsyncErrors(),t()}handleAsyncFails(e,t,a){e.setValidationAsyncData(!1,i.default.first(t.errors.get(e.path))),this.executeAsyncValidation(e),e.showAsyncErrors(),a()}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!0)}rules(e,t){const a=i.default.isString(e)?i.default.split(e,"|"):e,s=new this.validator;return i.default.filter(a,(e=>"async"===t?s.getRule(i.default.split(e,":")[0]).async:!s.getRule(i.default.split(e,":")[0]).async))}}t.DVR=l,t.default=e=>({class:l,config:e})},479:t=>{t.exports=e}},a={};return function e(s){var i=a[s];if(void 0!==i)return i.exports;var l=a[s]={exports:{}};return t[s].call(l.exports,l,l.exports,e),l.exports}(823)})()));
//# sourceMappingURL=MobxReactFormValidatorDVR.umd.min.js.map

@@ -100,3 +100,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

// extend ajv using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -103,0 +103,0 @@ form: this.state.form,

@@ -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 a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=a(r(479));class n{constructor({config:e={},state:t=null,promises:r=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=r,this.extend=e.extend,this.schema=e.schema,this.initAJV(e)}extendOptions(e={}){return Object.assign(e,{allowRequired:i.default.get(e,"allowRequired")||!1,errorDataPath:"property",allErrors:!0,coerceTypes:!0,v5:!0})}initAJV(e){const t=new(e.package||e)(this.extendOptions(e.options));i.default.isFunction(this.extend)&&this.extend({form:this.state.form,validator:t}),this.validator=t.compile(this.schema)}validate(e){const t={[e.path]:e.validatedValue},r=this.validator(this.parseValues(t));if(!(a=r)||"function"!=typeof a.then||"object"!=typeof a&&"function"!=typeof a){var a;this.handleSyncError(e,this.validator.errors)}else{const t=r.then((()=>e.setValidationAsyncData(!0))).catch((t=>t&&this.handleAsyncError(e,t.errors))).then((()=>this.executeAsyncValidation(e))).then((()=>e.showAsyncErrors()));this.promises.push(t)}}handleSyncError(e,t){const r=this.findError(e.key,t);if(i.default.isUndefined(r))return;const a=`${e.label} ${r.message}`;e.invalidate(a)}handleAsyncError(e,t){const r=this.findError(e.path,t);if(i.default.isUndefined(r))return;const a=`${e.label} ${r.message}`;e.setValidationAsyncData(!1,a)}findError(e,t){return i.default.find(t,(({dataPath:t})=>{let r;return r=i.default.trimStart(t,"."),r=i.default.trim(r,"['"),r=i.default.trim(r,"']"),i.default.includes(r,`${e}`)}))}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!0)}parseValues(e){return!0===i.default.get(this.config,"options.allowRequired")?i.default.omitBy(e,i.default.isEmpty||i.default.isNull||i.default.isUndefined||i.default.isNaN):e}}t.default=e=>({class:n,config:e})},479:t=>{t.exports=e}},r={};return function e(a){var i=r[a];if(void 0!==i)return i.exports;var n=r[a]={exports:{}};return t[a].call(n.exports,n,n.exports,e),n.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 a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=a(r(479));class n{constructor({config:e={},state:t=null,promises:r=[]}){Object.defineProperty(this,"promises",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=r,this.extend=e.extend,this.schema=e.schema,this.initAJV(e)}extendOptions(e={}){return Object.assign(e,{allowRequired:i.default.get(e,"allowRequired")||!1,errorDataPath:"property",allErrors:!0,coerceTypes:!0,v5:!0})}initAJV(e){const t=new(e.package||e)(this.extendOptions(e.options));"function"==typeof this.extend&&this.extend({form:this.state.form,validator:t}),this.validator=t.compile(this.schema)}validate(e){const t={[e.path]:e.validatedValue},r=this.validator(this.parseValues(t));if(!(a=r)||"function"!=typeof a.then||"object"!=typeof a&&"function"!=typeof a){var a;this.handleSyncError(e,this.validator.errors)}else{const t=r.then((()=>e.setValidationAsyncData(!0))).catch((t=>t&&this.handleAsyncError(e,t.errors))).then((()=>this.executeAsyncValidation(e))).then((()=>e.showAsyncErrors()));this.promises.push(t)}}handleSyncError(e,t){const r=this.findError(e.key,t);if(i.default.isUndefined(r))return;const a=`${e.label} ${r.message}`;e.invalidate(a)}handleAsyncError(e,t){const r=this.findError(e.path,t);if(i.default.isUndefined(r))return;const a=`${e.label} ${r.message}`;e.setValidationAsyncData(!1,a)}findError(e,t){return i.default.find(t,(({dataPath:t})=>{let r;return r=i.default.trimStart(t,"."),r=i.default.trim(r,"['"),r=i.default.trim(r,"']"),i.default.includes(r,`${e}`)}))}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!0)}parseValues(e){return!0===i.default.get(this.config,"options.allowRequired")?i.default.omitBy(e,i.default.isEmpty||i.default.isNull||i.default.isUndefined||i.default.isNaN):e}}t.default=e=>({class:n,config:e})},479:t=>{t.exports=e}},r={};return function e(a){var i=r[a];if(void 0!==i)return i.exports;var n=r[a]={exports:{}};return t[a].call(n.exports,n,n.exports,e),n.exports}(324)})()));
//# sourceMappingURL=MobxReactFormValidatorSVK.umd.min.js.map
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("_"), require("mobx"));
module.exports = factory(require("_"));
else if(typeof define === 'function' && define.amd)
define(["_", "mobx"], factory);
define(["_"], factory);
else if(typeof exports === 'object')
exports["MobxReactFormValidatorVJF"] = factory(require("_"), require("mobx"));
exports["MobxReactFormValidatorVJF"] = factory(require("_"));
else
root["MobxReactFormValidatorVJF"] = factory(root["_"], root["mobx"]);
})(self, (__WEBPACK_EXTERNAL_MODULE_lodash__, __WEBPACK_EXTERNAL_MODULE_mobx__) => {
root["MobxReactFormValidatorVJF"] = factory(root["_"]);
})(self, (__WEBPACK_EXTERNAL_MODULE_lodash__) => {
return /******/ (() => { // webpackBootstrap

@@ -28,3 +28,2 @@ /******/ "use strict";

const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "lodash"));
const mobx_1 = __webpack_require__(/*! mobx */ "mobx");
const isPromise = (obj) => !!obj &&

@@ -83,3 +82,3 @@ typeof obj.then === "function" &&

// extend using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -96,3 +95,3 @@ validator: this.validator,

// get validators from validate property
const $fn = (0, mobx_1.toJS)(field.validators);
const $fn = field.validators;
// map only if is an array of validator functions

@@ -102,6 +101,6 @@ if (lodash_1.default.isArray($fn)) {

}
// it's just one function
if (lodash_1.default.isFunction($fn)) {
this.collectData($fn, field);
}
// it's just one function // DEPRECATED
// if (typeof $fn === 'function') {
// this.collectData($fn, field);
// }
// execute the validation function

@@ -193,12 +192,2 @@ this.executeValidation(field);

/***/ }),
/***/ "mobx":
/*!***********************!*\
!*** external "mobx" ***!
\***********************/
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE_mobx__;
/***/ })

@@ -205,0 +194,0 @@

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("_"),require("mobx")):"function"==typeof define&&define.amd?define(["_","mobx"],t):"object"==typeof exports?exports.MobxReactFormValidatorVJF=t(require("_"),require("mobx")):e.MobxReactFormValidatorVJF=t(e._,e.mobx)}(self,((e,t)=>(()=>{"use strict";var a={69:function(e,t,a){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VJF=void 0;const o=i(a(479)),r=a(259),n=e=>!!e&&"function"==typeof e.then&&("object"==typeof e||"function"==typeof e);class s{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:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=a,this.extend=e.extend,this.validator=e.package||e,this.extendValidator()}extendValidator(){o.default.isFunction(this.extend)&&this.extend({validator:this.validator,form:this.state.form})}validate(e){if(!e.validators)return;const t=(0,r.toJS)(e.validators);o.default.isArray(t)&&t.map((t=>this.collectData(t,e))),o.default.isFunction(t)&&this.collectData(t,e),this.executeValidation(e)}collectData(e,t){const a=this.handleFunctionResult(e,t);if(n(a)){const e=a.then((e=>t.setValidationAsyncData(e[0],e[1]))).then((()=>this.executeAsyncValidation(t))).then((()=>t.showAsyncErrors()));this.promises.push(e)}else t.validationFunctionsData.unshift({valid:a[0],message:a[1]})}executeValidation(e){e.validationFunctionsData.map((t=>!1===t.valid&&e.invalidate(t.message)))}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!0)}handleFunctionResult(e,t){const a=e({validator:this.validator,form:this.state.form,field:t});return o.default.isArray(a)?[a[0]||!1,a[1]||"Error"]:o.default.isBoolean(a)?[a,"Error"]:o.default.isString(a)?[!1,a]:n(a)?a:[!1,"Error"]}}t.VJF=s,t.default=e=>({class:s,config:e})},479:t=>{t.exports=e},259:e=>{e.exports=t}},i={};return function e(t){var o=i[t];if(void 0!==o)return o.exports;var r=i[t]={exports:{}};return a[t].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,a){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VJF=void 0;const o=i(a(479)),r=e=>!!e&&"function"==typeof e.then&&("object"==typeof e||"function"==typeof e);class n{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:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=a,this.extend=e.extend,this.validator=e.package||e,this.extendValidator()}extendValidator(){"function"==typeof this.extend&&this.extend({validator:this.validator,form:this.state.form})}validate(e){if(!e.validators)return;const t=e.validators;o.default.isArray(t)&&t.map((t=>this.collectData(t,e))),this.executeValidation(e)}collectData(e,t){const a=this.handleFunctionResult(e,t);if(r(a)){const e=a.then((e=>t.setValidationAsyncData(e[0],e[1]))).then((()=>this.executeAsyncValidation(t))).then((()=>t.showAsyncErrors()));this.promises.push(e)}else t.validationFunctionsData.unshift({valid:a[0],message:a[1]})}executeValidation(e){e.validationFunctionsData.map((t=>!1===t.valid&&e.invalidate(t.message)))}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!0)}handleFunctionResult(e,t){const a=e({validator:this.validator,form:this.state.form,field:t});return o.default.isArray(a)?[a[0]||!1,a[1]||"Error"]:o.default.isBoolean(a)?[a,"Error"]:o.default.isString(a)?[!1,a]:r(a)?a:[!1,"Error"]}}t.VJF=n,t.default=e=>({class:n,config:e})},479:t=>{t.exports=e}},a={};return function e(i){var o=a[i];if(void 0!==o)return o.exports;var r=a[i]={exports:{}};return t[i].call(r.exports,r,r.exports,e),r.exports}(69)})()));
//# sourceMappingURL=MobxReactFormValidatorVJF.umd.min.js.map
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("_"));
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define(["_"], factory);
define([], factory);
else if(typeof exports === 'object')
exports["MobxReactFormValidatorYUP"] = factory(require("_"));
exports["MobxReactFormValidatorYUP"] = factory();
else
root["MobxReactFormValidatorYUP"] = factory(root["_"]);
})(self, (__WEBPACK_EXTERNAL_MODULE_lodash__) => {
root["MobxReactFormValidatorYUP"] = factory();
})(self, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/validators/YUP.ts":
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
(() => {
var exports = __webpack_exports__;
/*!*******************************!*\
!*** ./src/validators/YUP.ts ***!
\*******************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "lodash"));
/**

@@ -86,3 +81,3 @@ YUP - Dead simple Object schema validation

// extend using "extend" callback
if (lodash_1.default.isFunction(this.extend)) {
if (typeof this.extend === 'function') {
this.extend({

@@ -125,48 +120,4 @@ validator: this.validator,

})();
/***/ }),
/***/ "lodash":
/*!********************!*\
!*** external "_" ***!
\********************/
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE_lodash__;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__("./src/validators/YUP.ts");
/******/
/******/ return __webpack_exports__;

@@ -173,0 +124,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.MobxReactFormValidatorYUP=t(require("_")):e.MobxReactFormValidatorYUP=t(e._)}(self,(e=>(()=>{"use strict";var t={492:function(e,t,a){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(a(479));class r{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:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=a,this.extend=e.extend,this.validator=e.package||e,this.schema=e.schema(this.validator),this.extendValidator()}extendValidator(){s.default.isFunction(this.extend)&&this.extend({validator:this.validator,form:this.state.form})}validate(e){const t=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)))));this.promises.push(t)}handleAsyncPasses(e,t){e.setValidationAsyncData(!0),e.showAsyncErrors(),t()}handleAsyncFails(e,t,a){e.setValidationAsyncData(!1,a.errors[0]),this.executeAsyncValidation(e),e.showAsyncErrors(),t()}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!0)}}t.default=e=>({class:r,config:e})},479:t=>{t.exports=e}},a={};return function e(i){var s=a[i];if(void 0!==s)return s.exports;var r=a[i]={exports:{}};return t[i].call(r.exports,r,r.exports,e),r.exports}(492)})()));
!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:null}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"extend",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"validator",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state=t,this.promises=a,this.extend=e.extend,this.validator=e.package||e,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=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)))));this.promises.push(t)}handleAsyncPasses(e,t){e.setValidationAsyncData(!0),e.showAsyncErrors(),t()}handleAsyncFails(e,t,a){e.setValidationAsyncData(!1,a.errors[0]),this.executeAsyncValidation(e),e.showAsyncErrors(),t()}executeAsyncValidation(e){!1===e.validationAsyncData.valid&&e.invalidate(e.validationAsyncData.message,!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 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

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