-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.umd.min.js
1 lines (1 loc) · 2.34 KB
/
dist.umd.min.js
1
!function(r,e){if("function"==typeof define&&define.amd)define(["exports"],e);else if("undefined"!=typeof exports)e(exports);else{var t={exports:{}};e(t.exports),r.unknown=t.exports}}(this,function(r){"use strict";function e(r){return r instanceof Date?"date":r instanceof RegExp?"regexp":Array.isArray(r)?"array":typeof r}function t(r){return void 0===r||null===r||(r!==r||!(!r.trim||""!==r.trim()))}function n(r,e){return e?r+"."+e:""+r}function i(r,e){if("boolean"==typeof r||null==r)return r?{valid:!0,data:e}:{valid:!1,error:{"":f}};if("object"==typeof r){if(r.valid&&r.data)return r;if(!r.valid&&r.error)return r}return{valid:!0,data:r}}function a(r,f){var v=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments[3];if(null===f)return{valid:!1,error:{"":d}};if(null===r)return{valid:!0,data:f};var c=v.requirePrefix,g=void 0===c?"*":c,p=v.filter,h=void 0!==p&&p,b=v.strict,y=void 0!==b&&b,x=e(r),m=e(f);if(!y){if("string"===x&&"number"===m)return{valid:!0,data:String(f)};if("number"===x&&"string"===m){var j=Number(f);return isNaN(j)?{valid:!1,error:{"":u}}:{valid:!0,data:j}}}if("function"===x&&r.length>0)return i(r(f,v,s),f);if(x!==m)return{valid:!1,error:{"":u}};if(["number","boolean","string","date","regexp","undefined","function"].includes(x))return{valid:!0,data:f};if("array"===x){var O=function(){var e=[],t={},i=!1,o=[],u={};if(r.length>=2?(u=r[r.length-1],o.push.apply(o,r.slice(0,r.length-1))):o=r,u.min&&f.length<u.min||u.max&&f.length>u.max)return{v:{valid:!1,error:{"":l}}};if(0===o.length)return{v:{valid:!0,data:f}};for(var d=0;d<f.length;++d){(function(r){var l=r<o.length?o[r]:o[o.length-1];if(null===l)return e.push(f[r]),"continue";var d=a(l,f[r],u,r);if(d.valid)return e.push(d.data),"continue";i=!0,Object.keys(d.error).forEach(function(e){t[n(r,e)]=d.error[e]})})(d)}return i?{v:{valid:!1,error:t}}:{v:{valid:!0,data:e}}}();if("object"==typeof O)return O.v}f=Object.assign({},f);var k={},E={},N=!1;return Object.keys(r).forEach(function(e){var i=r[e],u=e.startsWith(g);u&&(e=e.substr(g.length));var l=f[e];if(delete f[e],u&&t(l)&&(N=!0,E[e]=o),void 0!==l)if(null!==i&&null!==l){var d=a(i,l,v);d.valid?k[e]=d.data:(N=!0,Object.keys(d.error).forEach(function(r){E[n(e,r)]=d.error[r]}))}else k[e]=l}),N?{valid:!1,error:E}:(h||Object.assign(k,f),{valid:!0,data:k})}Object.defineProperty(r,"__esModule",{value:!0});var o=1,u=2,l=3,f=4,d=5;r.default=a});