UNPKG

mobx-react-form

Version:
3 lines (2 loc) 908 B
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).MobxReactFormValidatorZOD=e(t._)}(this,function(t){"use strict";class e{promises;config;state;extend;validator;schema;constructor({config:t,state:e=null,promises:s=[]}){this.state=e,this.promises=s,this.config=t,this.extend=t?.extend,this.validator=t.package,this.schema=t.schema,this.extendValidator()}extendValidator(){"function"==typeof this.extend&&this.extend({validator:this.validator,form:this.state.form})}validate(e){const s=this.schema.safeParse(e.state.form.flatMapValues);if(s.success)return;const o=t.get(s.error.format(),e.path??"")?._errors;o?.length&&(e.validationErrorStack=o)}}return t=>({class:e,config:t})}); //# sourceMappingURL=MobxReactFormValidatorZOD.umd.min.js.map