Socket
Socket
Sign inDemoInstall

@hookform/resolvers

Package Overview
Dependencies
Maintainers
2
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hookform/resolvers - npm Package Compare versions

Comparing version 0.0.7-beta.1 to 0.0.7-beta.2

330

dist/index.cjs.development.js

@@ -7,239 +7,123 @@ 'use strict';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
const parseErrorSchema = (error, validateAllFieldCriteria) => Array.isArray(error.inner) && error.inner.length
? error.inner.reduce((previous, { path, message, type }) => {
const previousTypes = (previous[path] && previous[path].types) || {};
const key = path || type;
return Object.assign(Object.assign({}, previous), (key
? {
[key]: Object.assign(Object.assign({}, (previous[key] || {
message,
type,
})), (validateAllFieldCriteria
? {
types: Object.assign(Object.assign({}, previousTypes), { [type]: previousTypes[type]
? [...[].concat(previousTypes[type]), message]
: message }),
}
: {})),
}
: {}));
}, {})
: {
[error.path]: { message: error.message, type: error.type },
};
const yupResolver = (schema, options = {
abortEarly: false,
}) => async (values, context, validateAllFieldCriteria = false) => {
try {
if (options.context &&
"development" === 'development') {
// eslint-disable-next-line no-console
console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
}
return t;
};
return __assign.apply(this, arguments);
return {
values: (await schema.validate(values, Object.assign(Object.assign({}, options), { context }))),
errors: {},
};
}
catch (e) {
const parsedErrors = parseErrorSchema(e, validateAllFieldCriteria);
return {
values: {},
errors: validateAllFieldCriteria
? parsedErrors
: reactHookForm.transformToNestObject(parsedErrors),
};
}
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
var convertArrayToPathName = (paths) => paths
.reduce((previous, path, index) => `${previous}${typeof path === 'string'
? `${index > 0 ? '.' : ''}${path}`
: `[${path}]`}`, '')
.toString();
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var parseErrorSchema = function (error, validateAllFieldCriteria) {
var _a;
return Array.isArray(error.inner) && error.inner.length
? error.inner.reduce(function (previous, _a) {
var _b, _c;
var path = _a.path, message = _a.message, type = _a.type;
var previousTypes = (previous[path] && previous[path].types) || {};
return __assign(__assign({}, previous), (path
? (_b = {},
_b[path] = __assign(__assign({}, (previous[path] || {
message: message,
type: type,
})), (validateAllFieldCriteria
const parseErrorSchema$1 = (error, validateAllFieldCriteria) => Array.isArray(error.failures)
? error.failures.reduce((previous, { path, message = '', type }) => {
const currentPath = convertArrayToPathName(path);
return Object.assign(Object.assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? {
[currentPath]: reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type || '', message),
}
: {
[currentPath]: previous[currentPath] || Object.assign({ message,
type }, (validateAllFieldCriteria
? {
types: __assign(__assign({}, previousTypes), (_c = {}, _c[type] = previousTypes[type]
? __spreadArrays([].concat(previousTypes[type]), [message]) : message, _c)),
types: { [type || '']: message || true },
}
: {})),
_b) : {}));
}, {})
: (_a = {},
_a[error.path] = { message: error.message, type: error.type },
_a);
};
var yupResolver = function (schema, options) {
if (options === void 0) { options = {
abortEarly: false,
}; }
return function (values, context, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
var _a, e_1, parsedErrors;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
if (options.context &&
"development" === 'development') {
// eslint-disable-next-line no-console
console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
}
_a = {};
return [4 /*yield*/, schema.validate(values, __assign(__assign({}, options), { context: context }))];
case 1: return [2 /*return*/, (_a.values = (_b.sent()),
_a.errors = {},
_a)];
case 2:
e_1 = _b.sent();
parsedErrors = parseErrorSchema(e_1, validateAllFieldCriteria);
return [2 /*return*/, {
values: {},
errors: validateAllFieldCriteria
? parsedErrors
: reactHookForm.transformToNestObject(parsedErrors),
}];
case 3: return [2 /*return*/];
}
});
});
};
: {}));
}, {})
: [];
const superstructResolver = (schema) => async (values, _, validateAllFieldCriteria = false) => {
try {
return {
values: schema(values),
errors: {},
};
}
catch (e) {
return {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$1(e, validateAllFieldCriteria)),
};
}
};
var convertArrayToPathName = (function (paths) {
return paths
.reduce(function (previous, path, index) {
return "" + previous + (typeof path === 'string'
? "" + (index > 0 ? '.' : '') + path
: "[" + path + "]");
}, '')
.toString();
});
var parseErrorSchema$1 = function (error, validateAllFieldCriteria) {
return Array.isArray(error.failures)
? error.failures.reduce(function (previous, _a) {
var _b, _c, _d;
var path = _a.path, _e = _a.message, message = _e === void 0 ? '' : _e, type = _a.type;
var currentPath = convertArrayToPathName(path);
return __assign(__assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? (_b = {},
_b[currentPath] = reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type || '', message),
_b) : (_c = {},
_c[currentPath] = previous[currentPath] || __assign({ message: message,
type: type }, (validateAllFieldCriteria
const parseErrorSchema$2 = (error, validateAllFieldCriteria) => Array.isArray(error.details)
? error.details.reduce((previous, { path, message = '', type }) => {
const currentPath = convertArrayToPathName(path);
return Object.assign(Object.assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? {
[currentPath]: reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type, message),
}
: {
[currentPath]: previous[currentPath] || Object.assign({ message,
type }, (validateAllFieldCriteria
? {
types: (_d = {}, _d[type || ''] = message || true, _d),
types: { [type]: message || true },
}
: {})),
_c)
: {}));
}, {})
: [];
};
var superstructResolver = function (schema) { return function (values, _, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
try {
return [2 /*return*/, {
values: schema(values),
errors: {},
}];
}
catch (e) {
return [2 /*return*/, {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$1(e, validateAllFieldCriteria)),
}];
}
return [2 /*return*/];
});
});
}; };
var parseErrorSchema$2 = function (error, validateAllFieldCriteria) {
return Array.isArray(error.details)
? error.details.reduce(function (previous, _a) {
var _b, _c, _d;
var path = _a.path, _e = _a.message, message = _e === void 0 ? '' : _e, type = _a.type;
var currentPath = convertArrayToPathName(path);
return __assign(__assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? (_b = {},
_b[currentPath] = reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type, message),
_b) : (_c = {},
_c[currentPath] = previous[currentPath] || __assign({ message: message,
type: type }, (validateAllFieldCriteria
? {
types: (_d = {}, _d[type] = message || true, _d),
}
: {})),
_c)
: {}));
}, {})
: [];
};
var joiResolver = function (schema, options) {
if (options === void 0) { options = {
abortEarly: false,
}; }
return function (values, _, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
var _a, e_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
_a = {};
return [4 /*yield*/, schema.validateAsync(values, __assign({}, options))];
case 1: return [2 /*return*/, (_a.values = _b.sent(),
_a.errors = {},
_a)];
case 2:
e_1 = _b.sent();
return [2 /*return*/, {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$2(e_1, validateAllFieldCriteria)),
}];
case 3: return [2 /*return*/];
}
});
});
};
: {}));
}, {})
: [];
const joiResolver = (schema, options = {
abortEarly: false,
}) => async (values, _, validateAllFieldCriteria = false) => {
try {
return {
values: await schema.validateAsync(values, Object.assign({}, options)),
errors: {},
};
}
catch (e) {
return {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$2(e, validateAllFieldCriteria)),
};
}
};

@@ -246,0 +130,0 @@

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react-hook-form"),e=function(){return(e=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)};function t(r,e,t,n){return new(t||(t=Promise))((function(o,u){function a(r){try{i(n.next(r))}catch(r){u(r)}}function s(r){try{i(n.throw(r))}catch(r){u(r)}}function i(r){var e;r.done?o(r.value):(e=r.value,e instanceof t?e:new t((function(r){r(e)}))).then(a,s)}i((n=n.apply(r,e||[])).next())}))}function n(r,e){var t,n,o,u,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function s(u){return function(s){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(r,a)}catch(r){u=[6,r],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}function o(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;var n=Array(r),o=0;for(e=0;e<t;e++)for(var u=arguments[e],a=0,s=u.length;a<s;a++,o++)n[o]=u[a];return n}var u=function(r){return r.reduce((function(r,e,t){return r+("string"==typeof e?(t>0?".":"")+e:"["+e+"]")}),"").toString()},a=function(t,n){return Array.isArray(t.failures)?t.failures.reduce((function(t,o){var a,s,i,c=o.path,l=o.message,f=void 0===l?"":l,p=o.type,v=u(c);return e(e({},t),c?t[v]&&n?((a={})[v]=r.appendErrors(v,n,t,p||"",f),a):((s={})[v]=t[v]||e({message:f,type:p},n?{types:(i={},i[p||""]=f||!0,i)}:{}),s):{})}),{}):[]},s=function(t,n){return Array.isArray(t.details)?t.details.reduce((function(t,o){var a,s,i,c=o.path,l=o.message,f=void 0===l?"":l,p=o.type,v=u(c);return e(e({},t),c?t[v]&&n?((a={})[v]=r.appendErrors(v,n,t,p,f),a):((s={})[v]=t[v]||e({message:f,type:p},n?{types:(i={},i[p]=f||!0,i)}:{}),s):{})}),{}):[]};exports.joiResolver=function(o,u){return void 0===u&&(u={abortEarly:!1}),function(a,i,c){return void 0===c&&(c=!1),t(void 0,void 0,void 0,(function(){var t,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t={},[4,o.validateAsync(a,e({},u))];case 1:return[2,(t.values=n.sent(),t.errors={},t)];case 2:return i=n.sent(),[2,{values:{},errors:r.transformToNestObject(s(i,c))}];case 3:return[2]}}))}))}},exports.superstructResolver=function(e){return function(o,u,s){return void 0===s&&(s=!1),t(void 0,void 0,void 0,(function(){return n(this,(function(t){try{return[2,{values:e(o),errors:{}}]}catch(e){return[2,{values:{},errors:r.transformToNestObject(a(e,s))}]}return[2]}))}))}},exports.yupResolver=function(u,a){return void 0===a&&(a={abortEarly:!1}),function(s,i,c){return void 0===c&&(c=!1),t(void 0,void 0,void 0,(function(){var t,l,f;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),a.context,t={},[4,u.validate(s,e(e({},a),{context:i}))];case 1:return[2,(t.values=n.sent(),t.errors={},t)];case 2:return l=n.sent(),f=function(r,t){var n;return Array.isArray(r.inner)&&r.inner.length?r.inner.reduce((function(r,n){var u,a,s=n.path,i=n.message,c=n.type,l=r[s]&&r[s].types||{};return e(e({},r),s?((u={})[s]=e(e({},r[s]||{message:i,type:c}),t?{types:e(e({},l),(a={},a[c]=l[c]?o([].concat(l[c]),[i]):i,a))}:{}),u):{})}),{}):((n={})[r.path]={message:r.message,type:r.type},n)}(l,c),[2,{values:{},errors:c?f:r.transformToNestObject(f)}];case 3:return[2]}}))}))}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react-hook-form");var s=e=>e.reduce((e,s,r)=>`${e}${"string"==typeof s?`${r>0?".":""}${s}`:`[${s}]`}`,"").toString();const r=(r,t)=>Array.isArray(r.failures)?r.failures.reduce((r,{path:a,message:n="",type:c})=>{const o=s(a);return Object.assign(Object.assign({},r),a?r[o]&&t?{[o]:e.appendErrors(o,t,r,c||"",n)}:{[o]:r[o]||Object.assign({message:n,type:c},t?{types:{[c||""]:n||!0}}:{})}:{})},{}):[],t=(r,t)=>Array.isArray(r.details)?r.details.reduce((r,{path:a,message:n="",type:c})=>{const o=s(a);return Object.assign(Object.assign({},r),a?r[o]&&t?{[o]:e.appendErrors(o,t,r,c,n)}:{[o]:r[o]||Object.assign({message:n,type:c},t?{types:{[c]:n||!0}}:{})}:{})},{}):[];exports.joiResolver=(s,r={abortEarly:!1})=>async(a,n,c=!1)=>{try{return{values:await s.validateAsync(a,Object.assign({},r)),errors:{}}}catch(s){return{values:{},errors:e.transformToNestObject(t(s,c))}}},exports.superstructResolver=s=>async(t,a,n=!1)=>{try{return{values:s(t),errors:{}}}catch(s){return{values:{},errors:e.transformToNestObject(r(s,n))}}},exports.yupResolver=(s,r={abortEarly:!1})=>async(t,a,n=!1)=>{try{return r.context,{values:await s.validate(t,Object.assign(Object.assign({},r),{context:a})),errors:{}}}catch(s){const r=((e,s)=>Array.isArray(e.inner)&&e.inner.length?e.inner.reduce((e,{path:r,message:t,type:a})=>{const n=e[r]&&e[r].types||{},c=r||a;return Object.assign(Object.assign({},e),c?{[c]:Object.assign(Object.assign({},e[c]||{message:t,type:a}),s?{types:Object.assign(Object.assign({},n),{[a]:n[a]?[...[].concat(n[a]),t]:t})}:{})}:{})},{}):{[e.path]:{message:e.message,type:e.type}})(s,n);return{values:{},errors:n?r:e.transformToNestObject(r)}}};
//# sourceMappingURL=index.cjs.production.min.js.map
import { transformToNestObject, appendErrors } from 'react-hook-form';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
const parseErrorSchema = (error, validateAllFieldCriteria) => Array.isArray(error.inner) && error.inner.length
? error.inner.reduce((previous, { path, message, type }) => {
const previousTypes = (previous[path] && previous[path].types) || {};
const key = path || type;
return Object.assign(Object.assign({}, previous), (key
? {
[key]: Object.assign(Object.assign({}, (previous[key] || {
message,
type,
})), (validateAllFieldCriteria
? {
types: Object.assign(Object.assign({}, previousTypes), { [type]: previousTypes[type]
? [...[].concat(previousTypes[type]), message]
: message }),
}
: {})),
}
: {}));
}, {})
: {
[error.path]: { message: error.message, type: error.type },
};
const yupResolver = (schema, options = {
abortEarly: false,
}) => async (values, context, validateAllFieldCriteria = false) => {
try {
if (options.context &&
process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
}
return t;
};
return __assign.apply(this, arguments);
return {
values: (await schema.validate(values, Object.assign(Object.assign({}, options), { context }))),
errors: {},
};
}
catch (e) {
const parsedErrors = parseErrorSchema(e, validateAllFieldCriteria);
return {
values: {},
errors: validateAllFieldCriteria
? parsedErrors
: transformToNestObject(parsedErrors),
};
}
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
var convertArrayToPathName = (paths) => paths
.reduce((previous, path, index) => `${previous}${typeof path === 'string'
? `${index > 0 ? '.' : ''}${path}`
: `[${path}]`}`, '')
.toString();
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var parseErrorSchema = function (error, validateAllFieldCriteria) {
var _a;
return Array.isArray(error.inner) && error.inner.length
? error.inner.reduce(function (previous, _a) {
var _b, _c;
var path = _a.path, message = _a.message, type = _a.type;
var previousTypes = (previous[path] && previous[path].types) || {};
return __assign(__assign({}, previous), (path
? (_b = {},
_b[path] = __assign(__assign({}, (previous[path] || {
message: message,
type: type,
})), (validateAllFieldCriteria
const parseErrorSchema$1 = (error, validateAllFieldCriteria) => Array.isArray(error.failures)
? error.failures.reduce((previous, { path, message = '', type }) => {
const currentPath = convertArrayToPathName(path);
return Object.assign(Object.assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? {
[currentPath]: appendErrors(currentPath, validateAllFieldCriteria, previous, type || '', message),
}
: {
[currentPath]: previous[currentPath] || Object.assign({ message,
type }, (validateAllFieldCriteria
? {
types: __assign(__assign({}, previousTypes), (_c = {}, _c[type] = previousTypes[type]
? __spreadArrays([].concat(previousTypes[type]), [message]) : message, _c)),
types: { [type || '']: message || true },
}
: {})),
_b) : {}));
}, {})
: (_a = {},
_a[error.path] = { message: error.message, type: error.type },
_a);
};
var yupResolver = function (schema, options) {
if (options === void 0) { options = {
abortEarly: false,
}; }
return function (values, context, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
var _a, e_1, parsedErrors;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
if (options.context &&
process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
}
_a = {};
return [4 /*yield*/, schema.validate(values, __assign(__assign({}, options), { context: context }))];
case 1: return [2 /*return*/, (_a.values = (_b.sent()),
_a.errors = {},
_a)];
case 2:
e_1 = _b.sent();
parsedErrors = parseErrorSchema(e_1, validateAllFieldCriteria);
return [2 /*return*/, {
values: {},
errors: validateAllFieldCriteria
? parsedErrors
: transformToNestObject(parsedErrors),
}];
case 3: return [2 /*return*/];
}
});
});
};
: {}));
}, {})
: [];
const superstructResolver = (schema) => async (values, _, validateAllFieldCriteria = false) => {
try {
return {
values: schema(values),
errors: {},
};
}
catch (e) {
return {
values: {},
errors: transformToNestObject(parseErrorSchema$1(e, validateAllFieldCriteria)),
};
}
};
var convertArrayToPathName = (function (paths) {
return paths
.reduce(function (previous, path, index) {
return "" + previous + (typeof path === 'string'
? "" + (index > 0 ? '.' : '') + path
: "[" + path + "]");
}, '')
.toString();
});
var parseErrorSchema$1 = function (error, validateAllFieldCriteria) {
return Array.isArray(error.failures)
? error.failures.reduce(function (previous, _a) {
var _b, _c, _d;
var path = _a.path, _e = _a.message, message = _e === void 0 ? '' : _e, type = _a.type;
var currentPath = convertArrayToPathName(path);
return __assign(__assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? (_b = {},
_b[currentPath] = appendErrors(currentPath, validateAllFieldCriteria, previous, type || '', message),
_b) : (_c = {},
_c[currentPath] = previous[currentPath] || __assign({ message: message,
type: type }, (validateAllFieldCriteria
const parseErrorSchema$2 = (error, validateAllFieldCriteria) => Array.isArray(error.details)
? error.details.reduce((previous, { path, message = '', type }) => {
const currentPath = convertArrayToPathName(path);
return Object.assign(Object.assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? {
[currentPath]: appendErrors(currentPath, validateAllFieldCriteria, previous, type, message),
}
: {
[currentPath]: previous[currentPath] || Object.assign({ message,
type }, (validateAllFieldCriteria
? {
types: (_d = {}, _d[type || ''] = message || true, _d),
types: { [type]: message || true },
}
: {})),
_c)
: {}));
}, {})
: [];
};
var superstructResolver = function (schema) { return function (values, _, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
try {
return [2 /*return*/, {
values: schema(values),
errors: {},
}];
}
catch (e) {
return [2 /*return*/, {
values: {},
errors: transformToNestObject(parseErrorSchema$1(e, validateAllFieldCriteria)),
}];
}
return [2 /*return*/];
});
});
}; };
var parseErrorSchema$2 = function (error, validateAllFieldCriteria) {
return Array.isArray(error.details)
? error.details.reduce(function (previous, _a) {
var _b, _c, _d;
var path = _a.path, _e = _a.message, message = _e === void 0 ? '' : _e, type = _a.type;
var currentPath = convertArrayToPathName(path);
return __assign(__assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? (_b = {},
_b[currentPath] = appendErrors(currentPath, validateAllFieldCriteria, previous, type, message),
_b) : (_c = {},
_c[currentPath] = previous[currentPath] || __assign({ message: message,
type: type }, (validateAllFieldCriteria
? {
types: (_d = {}, _d[type] = message || true, _d),
}
: {})),
_c)
: {}));
}, {})
: [];
};
var joiResolver = function (schema, options) {
if (options === void 0) { options = {
abortEarly: false,
}; }
return function (values, _, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
var _a, e_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
_a = {};
return [4 /*yield*/, schema.validateAsync(values, __assign({}, options))];
case 1: return [2 /*return*/, (_a.values = _b.sent(),
_a.errors = {},
_a)];
case 2:
e_1 = _b.sent();
return [2 /*return*/, {
values: {},
errors: transformToNestObject(parseErrorSchema$2(e_1, validateAllFieldCriteria)),
}];
case 3: return [2 /*return*/];
}
});
});
};
: {}));
}, {})
: [];
const joiResolver = (schema, options = {
abortEarly: false,
}) => async (values, _, validateAllFieldCriteria = false) => {
try {
return {
values: await schema.validateAsync(values, Object.assign({}, options)),
errors: {},
};
}
catch (e) {
return {
values: {},
errors: transformToNestObject(parseErrorSchema$2(e, validateAllFieldCriteria)),
};
}
};

@@ -241,0 +125,0 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react-hook-form')) :
typeof define === 'function' && define.amd ? define(['exports', 'react-hook-form'], factory) :
(global = global || self, factory(global.ReactHookFormResolvers = {}, global.ReactHookForm));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react-hook-form')) :
typeof define === 'function' && define.amd ? define(['exports', 'react-hook-form'], factory) :
(global = global || self, factory(global.ReactHookFormResolvers = {}, global.ReactHookForm));
}(this, (function (exports, reactHookForm) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
const parseErrorSchema = (error, validateAllFieldCriteria) => Array.isArray(error.inner) && error.inner.length
? error.inner.reduce((previous, { path, message, type }) => {
const previousTypes = (previous[path] && previous[path].types) || {};
const key = path || type;
return Object.assign(Object.assign({}, previous), (key
? {
[key]: Object.assign(Object.assign({}, (previous[key] || {
message,
type,
})), (validateAllFieldCriteria
? {
types: Object.assign(Object.assign({}, previousTypes), { [type]: previousTypes[type]
? [...[].concat(previousTypes[type]), message]
: message }),
}
: {})),
}
: {}));
}, {})
: {
[error.path]: { message: error.message, type: error.type },
};
const yupResolver = (schema, options = {
abortEarly: false,
}) => async (values, context, validateAllFieldCriteria = false) => {
try {
if (options.context &&
"development" === 'development') {
// eslint-disable-next-line no-console
console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
}
return {
values: (await schema.validate(values, Object.assign(Object.assign({}, options), { context }))),
errors: {},
};
}
catch (e) {
const parsedErrors = parseErrorSchema(e, validateAllFieldCriteria);
return {
values: {},
errors: validateAllFieldCriteria
? parsedErrors
: reactHookForm.transformToNestObject(parsedErrors),
};
}
};
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
var convertArrayToPathName = (paths) => paths
.reduce((previous, path, index) => `${previous}${typeof path === 'string'
? `${index > 0 ? '.' : ''}${path}`
: `[${path}]`}`, '')
.toString();
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
const parseErrorSchema$1 = (error, validateAllFieldCriteria) => Array.isArray(error.failures)
? error.failures.reduce((previous, { path, message = '', type }) => {
const currentPath = convertArrayToPathName(path);
return Object.assign(Object.assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? {
[currentPath]: reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type || '', message),
}
: {
[currentPath]: previous[currentPath] || Object.assign({ message,
type }, (validateAllFieldCriteria
? {
types: { [type || '']: message || true },
}
: {})),
}
: {}));
}, {})
: [];
const superstructResolver = (schema) => async (values, _, validateAllFieldCriteria = false) => {
try {
return {
values: schema(values),
errors: {},
};
}
catch (e) {
return {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$1(e, validateAllFieldCriteria)),
};
}
};
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
const parseErrorSchema$2 = (error, validateAllFieldCriteria) => Array.isArray(error.details)
? error.details.reduce((previous, { path, message = '', type }) => {
const currentPath = convertArrayToPathName(path);
return Object.assign(Object.assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? {
[currentPath]: reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type, message),
}
: {
[currentPath]: previous[currentPath] || Object.assign({ message,
type }, (validateAllFieldCriteria
? {
types: { [type]: message || true },
}
: {})),
}
: {}));
}, {})
: [];
const joiResolver = (schema, options = {
abortEarly: false,
}) => async (values, _, validateAllFieldCriteria = false) => {
try {
return {
values: await schema.validateAsync(values, Object.assign({}, options)),
errors: {},
};
}
catch (e) {
return {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$2(e, validateAllFieldCriteria)),
};
}
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
exports.joiResolver = joiResolver;
exports.superstructResolver = superstructResolver;
exports.yupResolver = yupResolver;
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
Object.defineProperty(exports, '__esModule', { value: true });
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var parseErrorSchema = function (error, validateAllFieldCriteria) {
var _a;
return Array.isArray(error.inner) && error.inner.length
? error.inner.reduce(function (previous, _a) {
var _b, _c;
var path = _a.path, message = _a.message, type = _a.type;
var previousTypes = (previous[path] && previous[path].types) || {};
return __assign(__assign({}, previous), (path
? (_b = {},
_b[path] = __assign(__assign({}, (previous[path] || {
message: message,
type: type,
})), (validateAllFieldCriteria
? {
types: __assign(__assign({}, previousTypes), (_c = {}, _c[type] = previousTypes[type]
? __spreadArrays([].concat(previousTypes[type]), [message]) : message, _c)),
}
: {})),
_b) : {}));
}, {})
: (_a = {},
_a[error.path] = { message: error.message, type: error.type },
_a);
};
var yupResolver = function (schema, options) {
if (options === void 0) { options = {
abortEarly: false,
}; }
return function (values, context, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
var _a, e_1, parsedErrors;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
if (options.context &&
"development" === 'development') {
// eslint-disable-next-line no-console
console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
}
_a = {};
return [4 /*yield*/, schema.validate(values, __assign(__assign({}, options), { context: context }))];
case 1: return [2 /*return*/, (_a.values = (_b.sent()),
_a.errors = {},
_a)];
case 2:
e_1 = _b.sent();
parsedErrors = parseErrorSchema(e_1, validateAllFieldCriteria);
return [2 /*return*/, {
values: {},
errors: validateAllFieldCriteria
? parsedErrors
: reactHookForm.transformToNestObject(parsedErrors),
}];
case 3: return [2 /*return*/];
}
});
});
};
};
var convertArrayToPathName = (function (paths) {
return paths
.reduce(function (previous, path, index) {
return "" + previous + (typeof path === 'string'
? "" + (index > 0 ? '.' : '') + path
: "[" + path + "]");
}, '')
.toString();
});
var parseErrorSchema$1 = function (error, validateAllFieldCriteria) {
return Array.isArray(error.failures)
? error.failures.reduce(function (previous, _a) {
var _b, _c, _d;
var path = _a.path, _e = _a.message, message = _e === void 0 ? '' : _e, type = _a.type;
var currentPath = convertArrayToPathName(path);
return __assign(__assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? (_b = {},
_b[currentPath] = reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type || '', message),
_b) : (_c = {},
_c[currentPath] = previous[currentPath] || __assign({ message: message,
type: type }, (validateAllFieldCriteria
? {
types: (_d = {}, _d[type || ''] = message || true, _d),
}
: {})),
_c)
: {}));
}, {})
: [];
};
var superstructResolver = function (schema) { return function (values, _, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
try {
return [2 /*return*/, {
values: schema(values),
errors: {},
}];
}
catch (e) {
return [2 /*return*/, {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$1(e, validateAllFieldCriteria)),
}];
}
return [2 /*return*/];
});
});
}; };
var parseErrorSchema$2 = function (error, validateAllFieldCriteria) {
return Array.isArray(error.details)
? error.details.reduce(function (previous, _a) {
var _b, _c, _d;
var path = _a.path, _e = _a.message, message = _e === void 0 ? '' : _e, type = _a.type;
var currentPath = convertArrayToPathName(path);
return __assign(__assign({}, previous), (path
? previous[currentPath] && validateAllFieldCriteria
? (_b = {},
_b[currentPath] = reactHookForm.appendErrors(currentPath, validateAllFieldCriteria, previous, type, message),
_b) : (_c = {},
_c[currentPath] = previous[currentPath] || __assign({ message: message,
type: type }, (validateAllFieldCriteria
? {
types: (_d = {}, _d[type] = message || true, _d),
}
: {})),
_c)
: {}));
}, {})
: [];
};
var joiResolver = function (schema, options) {
if (options === void 0) { options = {
abortEarly: false,
}; }
return function (values, _, validateAllFieldCriteria) {
if (validateAllFieldCriteria === void 0) { validateAllFieldCriteria = false; }
return __awaiter(void 0, void 0, void 0, function () {
var _a, e_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
_a = {};
return [4 /*yield*/, schema.validateAsync(values, __assign({}, options))];
case 1: return [2 /*return*/, (_a.values = _b.sent(),
_a.errors = {},
_a)];
case 2:
e_1 = _b.sent();
return [2 /*return*/, {
values: {},
errors: reactHookForm.transformToNestObject(parseErrorSchema$2(e_1, validateAllFieldCriteria)),
}];
case 3: return [2 /*return*/];
}
});
});
};
};
exports.joiResolver = joiResolver;
exports.superstructResolver = superstructResolver;
exports.yupResolver = yupResolver;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=index.umd.development.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","react-hook-form"],r):r((e=e||self).ReactHookFormResolvers={},e.ReactHookForm)}(this,(function(e,r){"use strict";var t=function(){return(t=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function n(e,r,t,n){return new(t||(t=Promise))((function(o,u){function a(e){try{i(n.next(e))}catch(e){u(e)}}function s(e){try{i(n.throw(e))}catch(e){u(e)}}function i(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(a,s)}i((n=n.apply(e,r||[])).next())}))}function o(e,r){var t,n,o,u,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function s(u){return function(s){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}function u(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var n=Array(e),o=0;for(r=0;r<t;r++)for(var u=arguments[r],a=0,s=u.length;a<s;a++,o++)n[o]=u[a];return n}var a=function(e){return e.reduce((function(e,r,t){return e+("string"==typeof r?(t>0?".":"")+r:"["+r+"]")}),"").toString()},s=function(e,n){return Array.isArray(e.failures)?e.failures.reduce((function(e,o){var u,s,i,c=o.path,f=o.message,l=void 0===f?"":f,p=o.type,v=a(c);return t(t({},e),c?e[v]&&n?((u={})[v]=r.appendErrors(v,n,e,p||"",l),u):((s={})[v]=e[v]||t({message:l,type:p},n?{types:(i={},i[p||""]=l||!0,i)}:{}),s):{})}),{}):[]},i=function(e,n){return Array.isArray(e.details)?e.details.reduce((function(e,o){var u,s,i,c=o.path,f=o.message,l=void 0===f?"":f,p=o.type,v=a(c);return t(t({},e),c?e[v]&&n?((u={})[v]=r.appendErrors(v,n,e,p,l),u):((s={})[v]=e[v]||t({message:l,type:p},n?{types:(i={},i[p]=l||!0,i)}:{}),s):{})}),{}):[]};e.joiResolver=function(e,u){return void 0===u&&(u={abortEarly:!1}),function(a,s,c){return void 0===c&&(c=!1),n(void 0,void 0,void 0,(function(){var n,s;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),n={},[4,e.validateAsync(a,t({},u))];case 1:return[2,(n.values=o.sent(),n.errors={},n)];case 2:return s=o.sent(),[2,{values:{},errors:r.transformToNestObject(i(s,c))}];case 3:return[2]}}))}))}},e.superstructResolver=function(e){return function(t,u,a){return void 0===a&&(a=!1),n(void 0,void 0,void 0,(function(){return o(this,(function(n){try{return[2,{values:e(t),errors:{}}]}catch(e){return[2,{values:{},errors:r.transformToNestObject(s(e,a))}]}return[2]}))}))}},e.yupResolver=function(e,a){return void 0===a&&(a={abortEarly:!1}),function(s,i,c){return void 0===c&&(c=!1),n(void 0,void 0,void 0,(function(){var n,f,l;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),a.context,n={},[4,e.validate(s,t(t({},a),{context:i}))];case 1:return[2,(n.values=o.sent(),n.errors={},n)];case 2:return f=o.sent(),l=function(e,r){var n;return Array.isArray(e.inner)&&e.inner.length?e.inner.reduce((function(e,n){var o,a,s=n.path,i=n.message,c=n.type,f=e[s]&&e[s].types||{};return t(t({},e),s?((o={})[s]=t(t({},e[s]||{message:i,type:c}),r?{types:t(t({},f),(a={},a[c]=f[c]?u([].concat(f[c]),[i]):i,a))}:{}),o):{})}),{}):((n={})[e.path]={message:e.message,type:e.type},n)}(f,c),[2,{values:{},errors:c?l:r.transformToNestObject(l)}];case 3:return[2]}}))}))}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","react-hook-form"],s):s((e=e||self).ReactHookFormResolvers={},e.ReactHookForm)}(this,(function(e,s){"use strict";var r=e=>e.reduce((e,s,r)=>`${e}${"string"==typeof s?`${r>0?".":""}${s}`:`[${s}]`}`,"").toString();const t=(e,t)=>Array.isArray(e.failures)?e.failures.reduce((e,{path:a,message:n="",type:o})=>{const c=r(a);return Object.assign(Object.assign({},e),a?e[c]&&t?{[c]:s.appendErrors(c,t,e,o||"",n)}:{[c]:e[c]||Object.assign({message:n,type:o},t?{types:{[o||""]:n||!0}}:{})}:{})},{}):[],a=(e,t)=>Array.isArray(e.details)?e.details.reduce((e,{path:a,message:n="",type:o})=>{const c=r(a);return Object.assign(Object.assign({},e),a?e[c]&&t?{[c]:s.appendErrors(c,t,e,o,n)}:{[c]:e[c]||Object.assign({message:n,type:o},t?{types:{[o]:n||!0}}:{})}:{})},{}):[];e.joiResolver=(e,r={abortEarly:!1})=>async(t,n,o=!1)=>{try{return{values:await e.validateAsync(t,Object.assign({},r)),errors:{}}}catch(e){return{values:{},errors:s.transformToNestObject(a(e,o))}}},e.superstructResolver=e=>async(r,a,n=!1)=>{try{return{values:e(r),errors:{}}}catch(e){return{values:{},errors:s.transformToNestObject(t(e,n))}}},e.yupResolver=(e,r={abortEarly:!1})=>async(t,a,n=!1)=>{try{return r.context,{values:await e.validate(t,Object.assign(Object.assign({},r),{context:a})),errors:{}}}catch(e){const r=((e,s)=>Array.isArray(e.inner)&&e.inner.length?e.inner.reduce((e,{path:r,message:t,type:a})=>{const n=e[r]&&e[r].types||{},o=r||a;return Object.assign(Object.assign({},e),o?{[o]:Object.assign(Object.assign({},e[o]||{message:t,type:a}),s?{types:Object.assign(Object.assign({},n),{[a]:n[a]?[...[].concat(n[a]),t]:t})}:{})}:{})},{}):{[e.path]:{message:e.message,type:e.type}})(e,n);return{values:{},errors:n?r:s.transformToNestObject(r)}}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.production.min.js.map
{
"name": "@hookform/resolvers",
"version": "0.0.7-beta.1",
"version": "0.0.7-beta.2",
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct and etc.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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