peryl 1.4.39 → 1.4.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/cache.js +1 -0
- package/dist/cache.js.map +1 -1
- package/dist/debounce.js +1 -0
- package/dist/debounce.js.map +1 -1
- package/dist/dom.js +1 -0
- package/dist/dom.js.map +1 -1
- package/dist/encode.js +1 -0
- package/dist/encode.js.map +1 -1
- package/dist/events.js +1 -0
- package/dist/events.js.map +1 -1
- package/dist/form.js +1 -0
- package/dist/form.js.map +1 -1
- package/dist/google-analytics.js +1 -0
- package/dist/google-analytics.js.map +1 -1
- package/dist/hash.d.ts +3 -0
- package/dist/hash.js +16 -3
- package/dist/hash.js.map +1 -1
- package/dist/history.js +1 -0
- package/dist/history.js.map +1 -1
- package/dist/hsml-app.d.ts +2 -3
- package/dist/hsml-app.js +6 -6
- package/dist/hsml-app.js.map +1 -1
- package/dist/hsml-convert.js +1 -0
- package/dist/hsml-convert.js.map +1 -1
- package/dist/hsml-dom.js +1 -0
- package/dist/hsml-dom.js.map +1 -1
- package/dist/hsml-h.js +1 -0
- package/dist/hsml-h.js.map +1 -1
- package/dist/hsml-html.js +1 -0
- package/dist/hsml-html.js.map +1 -1
- package/dist/hsml-idom.js +2 -1
- package/dist/hsml-idom.js.map +1 -1
- package/dist/hsml-svac-ctrl.js +1 -0
- package/dist/hsml-svac-ctrl.js.map +1 -1
- package/dist/hsml-svac-html.js +1 -0
- package/dist/hsml-svac-html.js.map +1 -1
- package/dist/hsml-widget.js +1 -0
- package/dist/hsml-widget.js.map +1 -1
- package/dist/hsml.js +1 -0
- package/dist/hsml.js.map +1 -1
- package/dist/http.js +1 -0
- package/dist/http.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/load.js +1 -0
- package/dist/load.js.map +1 -1
- package/dist/objpaths.js +1 -0
- package/dist/objpaths.js.map +1 -1
- package/dist/router.js +1 -0
- package/dist/router.js.map +1 -1
- package/dist/settings.js +1 -0
- package/dist/settings.js.map +1 -1
- package/dist/signal.js +1 -0
- package/dist/signal.js.map +1 -1
- package/dist/template.js +1 -0
- package/dist/template.js.map +1 -1
- package/dist/tmpl.js +1 -0
- package/dist/tmpl.js.map +1 -1
- package/dist/umd/cache.js +1 -1
- package/dist/umd/cache.js.map +1 -1
- package/dist/umd/debounce.js +1 -1
- package/dist/umd/debounce.js.map +1 -1
- package/dist/umd/dom.js +1 -1
- package/dist/umd/dom.js.map +1 -1
- package/dist/umd/encode.js +1 -1
- package/dist/umd/encode.js.map +1 -1
- package/dist/umd/events.js +1 -1
- package/dist/umd/events.js.map +1 -1
- package/dist/umd/form.js +1 -1
- package/dist/umd/form.js.map +1 -1
- package/dist/umd/google-analytics.js +1 -1
- package/dist/umd/google-analytics.js.map +1 -1
- package/dist/umd/hash.js +1 -1
- package/dist/umd/hash.js.map +1 -1
- package/dist/umd/history.js +1 -1
- package/dist/umd/history.js.map +1 -1
- package/dist/umd/hsml-app.js +1 -1
- package/dist/umd/hsml-app.js.map +1 -1
- package/dist/umd/hsml-convert.js +1 -1
- package/dist/umd/hsml-convert.js.map +1 -1
- package/dist/umd/hsml-dom.js +1 -1
- package/dist/umd/hsml-dom.js.map +1 -1
- package/dist/umd/hsml-h.js +1 -1
- package/dist/umd/hsml-h.js.map +1 -1
- package/dist/umd/hsml-html.js +1 -1
- package/dist/umd/hsml-html.js.map +1 -1
- package/dist/umd/hsml-idom.js +1 -1
- package/dist/umd/hsml-idom.js.map +1 -1
- package/dist/umd/hsml-svac-ctrl.js +1 -1
- package/dist/umd/hsml-svac-ctrl.js.map +1 -1
- package/dist/umd/hsml-svac-html.js +1 -1
- package/dist/umd/hsml-svac-html.js.map +1 -1
- package/dist/umd/hsml-widget.js +1 -1
- package/dist/umd/hsml-widget.js.map +1 -1
- package/dist/umd/hsml.js +1 -1
- package/dist/umd/hsml.js.map +1 -1
- package/dist/umd/http.js +1 -1
- package/dist/umd/http.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/load.js +1 -1
- package/dist/umd/load.js.map +1 -1
- package/dist/umd/objpaths.js +1 -1
- package/dist/umd/objpaths.js.map +1 -1
- package/dist/umd/router.js +1 -1
- package/dist/umd/router.js.map +1 -1
- package/dist/umd/settings.js +1 -1
- package/dist/umd/settings.js.map +1 -1
- package/dist/umd/signal.js +1 -1
- package/dist/umd/signal.js.map +1 -1
- package/dist/umd/template.js +1 -1
- package/dist/umd/template.js.map +1 -1
- package/dist/umd/tmpl.js +1 -1
- package/dist/umd/tmpl.js.map +1 -1
- package/dist/umd/validators-moment.js +1 -1
- package/dist/umd/validators-moment.js.map +1 -1
- package/dist/umd/validators-numeral.js +1 -1
- package/dist/umd/validators-numeral.js.map +1 -1
- package/dist/umd/validators-object.js +1 -1
- package/dist/umd/validators-object.js.map +1 -1
- package/dist/umd/validators.js +1 -1
- package/dist/umd/validators.js.map +1 -1
- package/dist/validators-moment.js +1 -0
- package/dist/validators-moment.js.map +1 -1
- package/dist/validators-numeral.js +1 -0
- package/dist/validators-numeral.js.map +1 -1
- package/dist/validators-object.js +1 -0
- package/dist/validators-object.js.map +1 -1
- package/dist/validators.js +1 -4
- package/dist/validators.js.map +1 -1
- package/package.json +1 -1
- package/src/hash.ts +20 -2
- package/src/hsml-app.ts +6 -8
- package/src/hsml-idom.ts +2 -2
- package/src/validators.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/validators.ts","webpack:///./src/validators-numeral.ts","webpack:///external \"numeral\""],"names":["root","factory","exports","module","require","define","amd","a","i","window","__WEBPACK_EXTERNAL_MODULE__34__","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","emailRegex","phoneRgex","pscRgex","rodneCisloRgex","Validator","opts","msgs","str","err","obj","this","v","sto","strToObj","objCheck","format","ots","objToStr","undefined","tpl","tmpl","data","keys","map","k","reduce","replace","RegExp","String","super","required","options","join","indexOf","invalid_option","option","StringValidator","min","max","regexp","test","invalid_format","length","not_in_range","Number","isNaN","strict","num","toFixed","decimals","dateToLocaleString","date","toLocaleString","dateToLocaleDateString","toLocaleDateString","dateToStr","dateOnly","Date","getFullYear","getMonth","getDate","dt","parse","getTime","b","invalid_value","validators","field","validator","res","validate","valid","sr","console","log","NumeralValidator","locale","numeral","NumeralNumberValidator","nv","mObj"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,iBAC7B,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,WAAYJ,OAChB,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,YAAcH,EAAQD,EAAc,SAC1F,IAAI,IAAIQ,KAAKD,GAAuB,iBAAZL,QAAuBA,QAAUF,GAAMQ,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,SAASC,GACpB,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUX,QAGnC,IAAIC,EAASQ,EAAiBE,GAAY,CACzCL,EAAGK,EACHC,GAAG,EACHZ,QAAS,IAUV,OANAa,EAAQF,GAAUG,KAAKb,EAAOD,QAASC,EAAQA,EAAOD,QAASU,GAG/DT,EAAOW,GAAI,EAGJX,EAAOD,QA0Df,OArDAU,EAAoBK,EAAIF,EAGxBH,EAAoBM,EAAIP,EAGxBC,EAAoBO,EAAI,SAASjB,EAASkB,EAAMC,GAC3CT,EAAoBU,EAAEpB,EAASkB,IAClCG,OAAOC,eAAetB,EAASkB,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhET,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AAOI,KAAKJ,KAClB,IAAIE,GAAe,EAWnB,MAVI,QAASH,GACLI,EAAIxB,QAAUoB,EAAKiC,MACnB9B,GAAM,GAGV,QAASH,GACLI,EAAIxB,QAAUoB,EAAKgC,MACnB7B,GAAM,GAGVA,EACOF,EAAKqC,aACN,EAAAxB,IAAIb,EAAKqC,aACP,CACIN,IAAM,QAAShC,EAAS,GAAKA,EAAKgC,IAAO,GACzCC,IAAM,QAASjC,EAAS,GAAKA,EAAKiC,IAAO,GACzCsC,OAAS,WAAYvE,EACfA,EAAKuE,OAhHb,KAkHE7D,OAAS,WAAYV,EACfA,EAAKU,OAlHV,aAJH,eA2HP,GAGD,SAASN,EACAM,GAKf,OADA8D,EAAQD,OAAOlE,KAAKL,KAAKuE,QAhIX,MAiIP,CACHrE,IAAK,MAACE,EACA,GACAA,EAAIM,OAAOA,IAEPL,KAAKL,KAAKU,QArIP,aAsIbP,IAAK,KApHjB,qBA0HA,MAAasE,UACD,EAAA1E,UAIR,YAAYC,EAA6BC,GACrCuB,MAAMxB,EAAMC,GACZI,KAAKqE,GAAK,IAAIJ,EAAiBtE,EAAMC,GAG/B,SAASC,GACf,MAAM8D,EAAO3D,KAAKqE,GAAWlE,SAASN,GAItC,OAHI8D,EAAI5D,MACJ4D,EAAI5D,IAAM4D,EAAI5D,IAAIxB,SAEfoF,EAGD,SAAS5D,GACf,MAAMuE,EAAsB,iBAARvE,EAAmBoE,EAAQpE,GAAOA,EACtD,OAAQC,KAAKqE,GAAWjE,SAASkE,GAG3B,SAASvE,EACAM,GACf,MAAMiE,EAAsB,iBAARvE,EAAmBoE,EAAQpE,GAAOA,EACtD,OAAQC,KAAKqE,GAAW9D,SAAS+D,EAAMjE,IA1B/C,4B,iBCpJAzD,EAAOD,QAAUQ","file":"validators-numeral.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"numeral\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"numeral\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"numeral\")) : factory(root[\"numeral\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function(__WEBPACK_EXTERNAL_MODULE__34__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 33);\n","const requiredMsg = \"required\";\nconst notInRangeMsg = \"not_in_range\";\nconst invalidFormatMsg = \"invalid_format\";\nconst invalidOptionMsg = \"invalid_option\";\nconst invalidValueMsg = \"invalid_value\";\n\n// name@doamin.net\nexport const emailRegex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;\n\n// +421901123456 or +421 901 123 456 or +421-901-123-456 or 901123456 or 901 123 456 or 901-123-456\nexport const phoneRgex = /^(((00)([- ]?)|\\+)(\\d{1,3})([- ]?))?((\\d{3})([- ]?))((\\d{3})([- ]?))(\\d{3})$/;\n\n// 123 45 or 12345\nexport const pscRgex = /^\\d{3} ?\\d{2}$/;\n\n// 450115/8346\nexport const rodneCisloRgex = /^\\s*(\\d\\d)(\\d\\d)(\\d\\d)[ /]*(\\d\\d\\d)(\\d?)\\s*$/;\n\nexport abstract class Validator<TYPE, OPTS, MSGS> {\n\n readonly opts: OPTS;\n readonly msgs: MSGS;\n\n readonly str: string | null = null;\n readonly err: string | null = null;\n readonly obj: TYPE | null = null;\n\n constructor(opts?: OPTS, msgs?: MSGS) {\n this.opts = opts || {} as OPTS;\n this.msgs = msgs || {} as MSGS;\n }\n\n protected abstract strToObj(str?: string | null): { obj: TYPE | null, err: string };\n\n protected abstract objCheck(obj?: TYPE | null): string;\n\n protected abstract objToStr(obj?: TYPE | null,\n format?: string): { str: string, err: string };\n\n validate(value?: string | TYPE): { str?: string | null, obj?: TYPE | null, err: string } {\n if (typeof value === \"string\" || value === undefined || value === null) {\n const v = value as string | null | undefined;\n (this.str as any) = v;\n const sto = this.strToObj(v);\n (this.obj as any) = sto.obj;\n if (sto.err) {\n (this.err as any) = sto.err;\n return {\n str: (v === undefined || v === null) ? \"\" : v,\n obj: sto.obj,\n err: sto.err };\n }\n const err = this.objCheck(sto.obj);\n (this.err as any) = err;\n return {\n str: (v === undefined || v === null) ? \"\" : v,\n obj: sto.obj,\n err\n };\n } else {\n (this.str as any) = (value === undefined || value === null) ? null : (\"\" + value);\n const err = this.objCheck(value);\n (this.err as any) = err;\n return {\n str: this.str,\n obj: value,\n err\n };\n }\n }\n\n format(obj?: TYPE | null, format?: string): { str: string, err: string } {\n // const err = this.objCheck(obj);\n const ots = this.objToStr(obj, format);\n return {\n str: (ots.str === undefined || ots.str === null) ? \"\" : ots.str,\n // err: ots.err ? ots.err : err\n err: ots.err\n };\n }\n\n}\n\nexport function tpl(tmpl: string, data: { [k: string]: any }): string {\n return Object.keys(data)\n .map(k => [k, data[k]])\n .reduce((t, d) =>\n t.replace(new RegExp(`\\\\{\\\\{${d[0]}\\\\}\\\\}`, \"g\"), String(d[1])), tmpl);\n}\n\nexport interface ValidatorDataOpts {\n data?: { [key: string]: any };\n}\n\nexport interface SelectValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n options?: string[];\n}\n\nexport interface SelectValidatorMsgs {\n required?: string;\n invalid_option?: string;\n}\n\nexport class SelectValidator\n extends Validator<string, SelectValidatorOpts, SelectValidatorMsgs> {\n\n constructor(opts?: SelectValidatorOpts, msgs?: SelectValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: string | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n options: (\"options\" in opts)\n ? opts.options!.join(\", \")\n : \"\"\n })\n : requiredMsg\n };\n }\n }\n return {\n obj: str === undefined ? null : str,\n err: \"\"\n };\n }\n\n protected objCheck(obj?: string | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"options\" in opts) {\n if (obj && opts.options!.indexOf(obj) === -1) {\n return msgs.invalid_option\n ? tpl(msgs.invalid_option,\n {\n ...opts.data,\n option: obj === null ? \"\" : obj,\n options: (\"options\" in opts)\n ? opts.options!.join(\", \")\n : \"\"\n })\n : invalidOptionMsg;\n }\n }\n return \"\";\n }\n\n protected objToStr(obj?: string | null,\n format?: string): { str: string, err: string } {\n return { str: obj || \"\", err: \"\" };\n }\n\n}\n\nexport interface StringValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n min?: number;\n max?: number;\n regexp?: RegExp;\n}\n\nexport interface StringValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nexport class StringValidator\n extends Validator<string, StringValidatorOpts, StringValidatorMsgs> {\n\n constructor(opts?: StringValidatorOpts, msgs?: StringValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: string | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n regexp: (\"regexp\" in opts)\n ? (\"\" + opts.regexp)\n : \"\"\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n if (\"regexp\" in opts) {\n if (!opts.regexp!.test(str)) {\n return {\n obj: null,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n ...opts.data,\n regexp: (\"regexp\" in opts)\n ? (\"\" + opts.regexp)\n : \"\"\n })\n : invalidFormatMsg\n };\n }\n }\n return { obj: str , err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: string | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (obj.length > opts.max!) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (obj.length < opts.min!) {\n err = true;\n }\n }\n if ((\"min\" in opts) && (\"max\" in opts)) {\n if (obj.length > opts.max! && obj.length < opts.min!) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: string | null,\n format?: string): { str: string, err: string } {\n return { str: obj || \"\", err: \"\" };\n }\n\n}\n\nexport interface NumberValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n min?: number;\n max?: number;\n strict?: boolean;\n decimals?: number;\n}\n\nexport interface NumberValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nexport class NumberValidator\n extends Validator<number, NumberValidatorOpts, NumberValidatorMsgs> {\n\n constructor(opts?: NumberValidatorOpts, msgs?: NumberValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: number | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n const n = Number(str);\n let err: boolean = false;\n if (isNaN(n)) {\n err = true;\n }\n if (opts.strict && (str !== this.objToStr(n).str)) {\n err = true;\n }\n if (err) {\n const num = isNaN(n) ? 1234.45 : n;\n return {\n obj: isNaN(n) ? null : n,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n ...opts.data,\n num: this.objToStr(num).str || \"\"\n })\n : invalidFormatMsg\n };\n }\n return { obj: n, err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: number | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (obj > opts.max!) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (obj < opts.min!) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: number | null,\n format?: string): { str: string, err: string } {\n let str;\n if (obj === undefined || obj === null) {\n str = \"\";\n } else {\n if (\"decimals\" in this.opts) {\n str = obj.toFixed(this.opts.decimals);\n } else {\n str = String(obj);\n }\n }\n return {\n str,\n err: \"\"\n };\n }\n\n}\n\nexport interface DateValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n min?: Date;\n max?: Date;\n dateOnly?: boolean;\n // strict?: boolean;\n\n}\n\nexport interface DateValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nconst dateToLocaleString = (date: Date) => date.toLocaleString();\nconst dateToLocaleDateString = (date: Date) => date.toLocaleDateString();\n\nexport class DateValidator\n extends Validator<Date, DateValidatorOpts, DateValidatorMsgs> {\n\n dateToStr: (date: Date) => string;\n\n constructor(opts?: DateValidatorOpts, msgs?: DateValidatorMsgs) {\n super(opts, msgs);\n this.dateToStr = opts?.dateOnly ? dateToLocaleDateString : dateToLocaleString;\n if (opts?.dateOnly && opts?.min) {\n opts.min = new Date(opts.min.getFullYear(), opts.min.getMonth(), opts.min.getDate());\n }\n if (opts?.dateOnly && opts?.max) {\n opts.max = new Date(opts.max.getFullYear(), opts.max.getMonth(), opts.max.getDate() + 1);\n }\n }\n\n protected strToObj(str?: string | null): { obj: Date | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n min: (\"min\" in opts && opts.min) ? this.dateToStr(opts.min) : \"\",\n max: (\"max\" in opts && opts.max) ? this.dateToStr(opts.max) : \"\"\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n const dt = Date.parse(str);\n let d = new Date(dt);\n if (opts.dateOnly) {\n d = new Date(d.getFullYear(), d.getMonth(), d.getDate());\n }\n let err: boolean = false;\n if (isNaN(dt)) {\n err = true;\n }\n // if (opts.strict && (str !== this.objToStr(d).str)) {\n // err = true;\n // }\n if (err) {\n const date = isNaN(dt) ? new Date() : d;\n return {\n obj: isNaN(dt) ? null : d,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n ...opts.data,\n date: this.objToStr(date).str || \"\"\n })\n : invalidFormatMsg\n };\n }\n return { obj: d, err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: Date | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (opts.max && obj.getTime() > opts.max.getTime()) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (opts.min && obj < opts.min) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n ...opts.data,\n min: (\"min\" in opts && opts.min) ? this.dateToStr(opts.min) : \"\",\n max: (\"max\" in opts && opts.max) ? this.dateToStr(opts.max) : \"\"\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: Date | null,\n format?: string): { str: string, err: string } {\n return {\n str: (obj === undefined || obj === null) ? \"\" : this.dateToStr(obj),\n err: \"\"\n };\n }\n\n}\n\nexport interface BooleanValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n value?: boolean;\n}\n\nexport interface BooleanValidatorMsgs {\n required?: string;\n invalid_value?: string;\n}\n\nexport class BooleanValidator\n extends Validator<boolean, BooleanValidatorOpts, BooleanValidatorMsgs> {\n\n constructor(opts?: BooleanValidatorOpts, msgs?: BooleanValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: boolean | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data\n })\n : requiredMsg\n };\n }\n }\n let b;\n switch (str) {\n case \"true\":\n case \"1\":\n case \"on\":\n case \"yes\":\n b = true;\n break;\n default:\n b = false;\n }\n return { obj: b, err: \"\" };\n }\n\n protected objCheck(obj?: boolean | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err = false;\n if (\"value\" in opts) {\n if (obj !== opts.value) {\n err = true;\n }\n }\n if (err) {\n return msgs.invalid_value\n ? tpl(msgs.invalid_value,\n {\n ...opts.data,\n value: (\"value\" in opts) ? (\"\" + opts.value) : \"\",\n })\n : invalidValueMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: boolean | null,\n format?: string): { str: string, err: string } {\n return {\n str: (obj === undefined || obj === null) ? \"\" : (\"\" + obj),\n err: \"\"\n };\n }\n\n}\n\ntype FormValidators<TYPE> = { [key in keyof TYPE]: Validator<any, any, any> };\n\nexport type Str<TYPE> = { [key in keyof TYPE]: string };\nexport type Obj<TYPE> = { [key in keyof TYPE]: any };\nexport type Err<TYPE> = { [key in keyof TYPE]: string };\n\nexport interface FormValidatorData<TYPE> {\n str: Str<TYPE>;\n obj: Obj<TYPE>;\n err: Err<TYPE>;\n valid: boolean;\n}\n\nexport class FormValidator<TYPE extends { [key: string]: any }> {\n\n readonly validators: FormValidators<TYPE> = {} as FormValidators<TYPE>;\n\n readonly str?: Str<TYPE>;\n readonly obj?: Obj<TYPE>;\n readonly err?: Err<TYPE>;\n\n readonly valid?: boolean;\n\n addValidator(field: keyof TYPE, validator: Validator<any, any, any>): this {\n this.validators[field] = validator;\n return this;\n }\n\n validate(data: { [key in keyof TYPE]?: string }): this {\n const res = Object.keys(this.validators)\n .reduce(\n (a, k) => {\n const v = (data as any)[k];\n const r = (this.validators as any)[k].validate(v);\n (a.str as any)[k] = r.str;\n (a.obj as any)[k] = r.obj;\n (a.err as any)[k] = r.err;\n r.err && (a.valid = false);\n return a;\n },\n { str: {}, obj: {}, err: {}, valid: true });\n (this.str as any) = res.str;\n (this.obj as any) = res.obj;\n (this.err as any) = res.err;\n (this.valid as any) = res.valid;\n return this;\n }\n\n format(data: { [key in keyof TYPE]: any }): this {\n const res = Object.keys(this.validators)\n .reduce(\n (a, k) => {\n const v = (data as any)[k];\n const r = (this.validators as any)[k].format(v);\n (a.str as any)[k] = r.str;\n (a.obj as any)[k] = v;\n (a.err as any)[k] = r.err;\n r.err && (a.valid = false);\n return a;\n },\n { str: {}, obj: {}, err: {}, valid: true });\n (this.str as any) = res.str;\n (this.obj as any) = res.obj;\n (this.err as any) = res.err;\n (this.valid as any) = res.valid;\n return this;\n }\n\n data(): FormValidatorData<TYPE> {\n return {\n str: this.str!,\n obj: this.obj!,\n err: this.err!,\n valid: this.valid!\n };\n }\n\n}\n\n\n// TEST\n\n// const sv = new StringValidator(\n// {\n// required: true,\n// min: 3,\n// max: 5,\n// // regexp: /^[0123]+$/\n// data: {\n// xxx: \"xXx\"\n// }\n// },\n// {\n// required: \"required {{min}} {{max}} {{regexp}}\",\n// invalid_format: \"invalid_format {{regexp}}\",\n// not_in_range: \"not_in_range {{min}} {{max}} | data.xxx={{xxx}}\"\n// });\n\n// [\n// \"x1234\",\n// \"x1234y\",\n// \"xy\"\n// ].forEach(v => {\n// console.log();\n// console.log(v);\n// const r = sv.validate(v);\n// console.log(r);\n// if (r.obj) {\n// const f = sv.format(r.obj);\n// console.log(f);\n// }\n// });\n\n// console.log();\n\n// const nv = new NumberValidator(\n// {\n// required: true,\n// min: 3,\n// max: 500000,\n// decimals: 2,\n// strict: true\n// },\n// {\n// required: \"required {{min}} {{max}}\",\n// invalid_format: \"invalid_format {{num}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// console.log(nv.format(undefined));\n// console.log(nv.format(12345.6789));\n\n// console.log(nv.validate(\"12345.6789\"));\n// console.log(nv.validate(\"12345,6789\"));\n// console.log(nv.validate(\"12,345.6789\"));\n\n// const dv = new DateValidator(\n// {\n// required: false,\n// // min: new Date(),\n// max: new Date(),\n// clearTime: false\n// // strict: true\n// },\n// {\n// required: \"required {{min}} {{max}}\",\n// invalid_format: \"invalid_format {{date}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// console.log(dv.opts);\n\n// console.log(dv.format(undefined));\n\n// console.log(dv.format(new Date));\n\n// console.log(dv.validate(\"9/17/2020, 10:46:07 AM\"));\n// console.log(dv.format(dv.obj).str);\n// console.log(dv.validate(\"9/17/2020\"));\n// console.log(dv.format(dv.obj).str);\n// console.log(dv.validate(\"2020-09-17T08:46:07.000Z\"));\n// console.log(dv.format(dv.obj).str);\n// console.log(dv.validate(\"\"));\n// console.log(dv.format(dv.obj).str);\n\n// console.log(new Date().toString());\n// console.log(new Date().toDateString());\n// console.log(new Date().toTimeString());\n// console.log(new Date().toLocaleString());\n// console.log(new Date().toLocaleDateString());\n// console.log(new Date().toLocaleTimeString());\n// console.log();\n// console.log(new Date(Date.parse(new Date().toString())));\n// console.log(new Date(Date.parse(new Date().toDateString())));\n// console.log(new Date(Date.parse(new Date().toTimeString())));\n// console.log(new Date(Date.parse(new Date().toLocaleString())));\n// console.log(new Date(Date.parse(new Date().toLocaleDateString())));\n// console.log(new Date(Date.parse(new Date().toLocaleTimeString())));\n\n// const formData = { str: \"123a\", num: \"123456.789\", date: \"9/17/2020, 10:46:07 AM\" };\n// const formData = { str: \"\", num: \"\", date: \"\" };\n// const formData = { str: undefined, num: undefined, date: undefined };\n\n// const fv = new FormValidator<typeof formData>()\n// .addValidator(\"str\", sv)\n// .addValidator(\"num\", nv)\n// .addValidator(\"date\", dv)\n// .validate(formData);\n\n// console.log(fv.data());\n\n// fv.format(fv.obj!);\n// console.log(fv);\n\n// const ovData = { str: \"123a\", num: \"123.45\", date: \"02.01.2019 12:12\" };\n\n// const ov = new ObjectValidator<typeof ovData>()\n// .addValidator(\"str\", sv)\n// .addValidator(\"num\", nv)\n// // .addValidator(\"date\", dv)\n// .validate(ovData);\n\n// // console.log(ov);\n\n// ov.format(ov.obj!);\n// console.log(ov);\n\n// console.log();\n\n// interface ReportFormData {\n// spz: string;\n// tachometer: string;\n// dateCreated: string;\n// user: {\n// // name: string[];\n// email: string;\n// };\n// }\n\n// const dov = new ObjectValidator<ReportFormData>()\n// .addValidator(\"spz\", new StringValidator({ required: true }))\n// .addValidator(\"tachometer\", new NumberValidator({ required: true, min: 1 } ))\n// .addValidator(\"dateCreated\", new StringValidator({ required: true }))\n// .addValidator(\"user\", new ObjectValidator<ReportFormData[\"user\"]>()\n// .addValidator(\"email\", new StringValidator({ required: true}))\n// // .addValidator(\"name\", { })\n// // new ArrayValidator({\n// // required: true,\n// // validator: new StringValidator({ required: true })\n// // })\n// );\n\n// dov.validate(\n// {\n// spz: \"dasdas\",\n// tachometer: \"111222\",\n// // dateCreated: \"10.02.2019\",\n// user: {\n// // email: \"dsafasdf\",\n// }\n// },\n// {\n// dateCreated: \"01.03.2011\",\n// spz: \"32ds9f0f\",\n// tachometer: \"3213214214\",\n// user: {\n// email: \"sadmaskdmk2@dsadsamkl.com\"\n// }\n// });\n\n// const avn = new ArrayValidator<number>(new NumberValidator());\n// const rn = avn.validate([345, 123]);\n// console.log(rn);\n\n\n// interface D {\n// a: number;\n// b?: string;\n// }\n\n// const av = new ArrayValidator<T>(new ObjectValidator<T>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// );\n\n// const d: D[] = [\n// { a: 123, b: \"text\" },\n// // { a: 5.6, b: \"\" },\n// { a: 5.6 }\n// ];\n\n// const r = av.validate(d);\n// console.log(r);\n\n// const ro = new ObjectValidator<T>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// .validate({\n// a: \"5.6\",\n// b: undefined\n// // b: \"text\"\n// });\n// console.log(\"---\", ro);\n\n// const v = new StringValidator({ required: true });\n// const str = undefined;\n// const sr = v.validate(str!);\n// console.log(sr);\n\nconst v = new StringValidator({ required: true, min: 8 });\nconst str = \"\";\nconst sr = v.format(str);\nconsole.log(sr, v);\n","import { Validator, tpl } from \"./validators\";\nimport * as numeral from \"numeral\";\n\nconst requiredMsg = \"required\";\nconst notInRangeMsg = \"not_in_range\";\nconst invalidFormatMsg = \"invalid_format\";\n\nconst localeDefault = \"en\";\nconst numFormatDefault = \"0,0.[00]\";\n\n\nexport interface NumeralValidatorOpts {\n required?: boolean;\n min?: number;\n max?: number;\n locale?: string;\n format?: string;\n strict?: boolean;\n}\n\nexport interface NumeralValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nexport class NumeralValidator\n extends Validator<Numeral, NumeralValidatorOpts, NumeralValidatorMsgs> {\n\n constructor(opts?: NumeralValidatorOpts, msgs?: NumeralValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: Numeral | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n locale: (\"locale\" in opts)\n ? opts.locale!\n : localeDefault,\n format: (\"format\" in opts)\n ? opts.format!\n : numFormatDefault\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n numeral.locale(opts.locale || localeDefault);\n const n = numeral(str);\n let err: boolean = false;\n if (n.value() === null) {\n err = true;\n }\n if (\"strict\" in opts) {\n if (opts.strict && (str !== this.objToStr(n).str)) {\n err = true;\n }\n }\n if (err) {\n const num = (n.value() !== null) ? n : numeral(1234.45);\n return {\n obj: (n.value() !== null) ? n : null,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n num: this.objToStr(num).str || \"\",\n locale: (\"locale\" in opts)\n ? opts.locale!\n : localeDefault,\n format: (\"format\" in opts)\n ? opts.format!\n : numFormatDefault\n })\n : invalidFormatMsg\n };\n }\n return { obj: n, err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: Numeral | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n // if (obj.constructor === Number) {\n // obj = numeral(obj);\n // }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (obj.value() > opts.max!) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (obj.value() < opts.min!) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n locale: (\"locale\" in opts)\n ? opts.locale!\n : localeDefault,\n format: (\"format\" in opts)\n ? opts.format!\n : numFormatDefault\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: Numeral | null,\n format?: string): { str: string, err: string } {\n // if (obj && obj.constructor === Number) {\n // obj = numeral(obj);\n // }\n numeral.locale(this.opts.locale || localeDefault);\n return {\n str: (obj === undefined || obj === null)\n ? \"\"\n : obj.format(format\n ? format\n : this.opts.format || numFormatDefault),\n err: \"\"\n };\n }\n\n}\n\nexport class NumeralNumberValidator\n extends Validator<number, NumeralValidatorOpts, NumeralValidatorMsgs> {\n\n nv: NumeralValidator;\n\n constructor(opts?: NumeralValidatorOpts, msgs?: NumeralValidatorMsgs) {\n super(opts, msgs);\n this.nv = new NumeralValidator(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: number | null, err: string } {\n const res = (this.nv as any).strToObj(str);\n if (res.obj) {\n res.obj = res.obj.value();\n }\n return res;\n }\n\n protected objCheck(obj?: number | null): string {\n const mObj = typeof obj === \"number\" ? numeral(obj) : obj;\n return (this.nv as any).objCheck(mObj);\n }\n\n protected objToStr(obj?: number | null,\n format?: string): { str: string, err: string } {\n const mObj = typeof obj === \"number\" ? numeral(obj) : obj;\n return (this.nv as any).objToStr(mObj, format);\n }\n\n}\n\n// TEST\n\n// import \"numeral/locales\";\n\n// // const nv = new NumeralValidator(\n// const nv = new NumeralNumberValidator(\n// {\n// required: true,\n// min: 3,\n// max: 5000,\n// locale: \"sk\",\n// format: \"0,0.0[00]\",\n// strict: true\n// },\n// {\n// required: \"required {{min}} {{max}} {{locale}} {{format}}\",\n// invalid_format: \"invalid_format {{num}} {{locale}} {{format}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// [\n// \"1234,56\",\n// \"1 234,56\",\n// \"1 234,56y\",\n// \"xy\"\n// ].forEach(v => {\n// console.log();\n// console.log(v);\n// const r = nv.validate(v);\n// console.log(r);\n// if (r.obj) {\n// const f = nv.format(r.obj);\n// console.log(f);\n// }\n// });\n","module.exports = __WEBPACK_EXTERNAL_MODULE__34__;"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/validators.ts","webpack:///./src/validators-numeral.ts","webpack:///external \"numeral\""],"names":["root","factory","exports","module","require","define","amd","a","i","window","__WEBPACK_EXTERNAL_MODULE__34__","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","emailRegex","phoneRgex","pscRgex","rodneCisloRgex","Validator","opts","msgs","str","err","obj","this","v","sto","strToObj","objCheck","format","ots","objToStr","undefined","tpl","tmpl","data","keys","map","k","reduce","replace","RegExp","String","super","required","options","join","indexOf","invalid_option","option","min","max","regexp","test","invalid_format","length","not_in_range","Number","isNaN","strict","num","toFixed","decimals","dateToLocaleString","date","toLocaleString","dateToLocaleDateString","toLocaleDateString","dateToStr","dateOnly","Date","getFullYear","getMonth","getDate","dt","parse","getTime","b","invalid_value","validators","field","validator","res","validate","valid","NumeralValidator","locale","numeral","NumeralNumberValidator","nv","mObj"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,iBAC7B,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,WAAYJ,OAChB,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,YAAcH,EAAQD,EAAc,SAC1F,IAAI,IAAIQ,KAAKD,GAAuB,iBAAZL,QAAuBA,QAAUF,GAAMQ,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,SAASC,GACpB,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUX,QAGnC,IAAIC,EAASQ,EAAiBE,GAAY,CACzCL,EAAGK,EACHC,GA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AAM7D,IA1B/C,4B,iBCpJAzD,EAAOD,QAAUQ","file":"validators-numeral.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"numeral\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"numeral\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"numeral\")) : factory(root[\"numeral\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function(__WEBPACK_EXTERNAL_MODULE__34__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 33);\n","const requiredMsg = \"required\";\nconst notInRangeMsg = \"not_in_range\";\nconst invalidFormatMsg = \"invalid_format\";\nconst invalidOptionMsg = \"invalid_option\";\nconst invalidValueMsg = \"invalid_value\";\n\n// name@doamin.net\nexport const emailRegex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;\n\n// +421901123456 or +421 901 123 456 or +421-901-123-456 or 901123456 or 901 123 456 or 901-123-456\nexport const phoneRgex = /^(((00)([- ]?)|\\+)(\\d{1,3})([- ]?))?((\\d{3})([- ]?))((\\d{3})([- ]?))(\\d{3})$/;\n\n// 123 45 or 12345\nexport const pscRgex = /^\\d{3} ?\\d{2}$/;\n\n// 450115/8346\nexport const rodneCisloRgex = /^\\s*(\\d\\d)(\\d\\d)(\\d\\d)[ /]*(\\d\\d\\d)(\\d?)\\s*$/;\n\nexport abstract class Validator<TYPE, OPTS, MSGS> {\n\n readonly opts: OPTS;\n readonly msgs: MSGS;\n\n readonly str: string | null = null;\n readonly err: string | null = null;\n readonly obj: TYPE | null = null;\n\n constructor(opts?: OPTS, msgs?: MSGS) {\n this.opts = opts || {} as OPTS;\n this.msgs = msgs || {} as MSGS;\n }\n\n protected abstract strToObj(str?: string | null): { obj: TYPE | null, err: string };\n\n protected abstract objCheck(obj?: TYPE | null): string;\n\n protected abstract objToStr(obj?: TYPE | null,\n format?: string): { str: string, err: string };\n\n validate(value?: string | TYPE): { str?: string | null, obj?: TYPE | null, err: string } {\n if (typeof value === \"string\" || value === undefined || value === null) {\n const v = value as string | null | undefined;\n (this.str as any) = v;\n const sto = this.strToObj(v);\n (this.obj as any) = sto.obj;\n if (sto.err) {\n (this.err as any) = sto.err;\n return {\n str: (v === undefined || v === null) ? \"\" : v,\n obj: sto.obj,\n err: sto.err };\n }\n const err = this.objCheck(sto.obj);\n (this.err as any) = err;\n return {\n str: (v === undefined || v === null) ? \"\" : v,\n obj: sto.obj,\n err\n };\n } else {\n (this.str as any) = (value === undefined || value === null) ? null : (\"\" + value);\n const err = this.objCheck(value);\n (this.err as any) = err;\n return {\n str: this.str,\n obj: value,\n err\n };\n }\n }\n\n format(obj?: TYPE | null, format?: string): { str: string, err: string } {\n // const err = this.objCheck(obj);\n const ots = this.objToStr(obj, format);\n return {\n str: (ots.str === undefined || ots.str === null) ? \"\" : ots.str,\n // err: ots.err ? ots.err : err\n err: ots.err\n };\n }\n\n}\n\nexport function tpl(tmpl: string, data: { [k: string]: any }): string {\n return Object.keys(data)\n .map(k => [k, data[k]])\n .reduce((t, d) =>\n t.replace(new RegExp(`\\\\{\\\\{${d[0]}\\\\}\\\\}`, \"g\"), String(d[1])), tmpl);\n}\n\nexport interface ValidatorDataOpts {\n data?: { [key: string]: any };\n}\n\nexport interface SelectValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n options?: string[];\n}\n\nexport interface SelectValidatorMsgs {\n required?: string;\n invalid_option?: string;\n}\n\nexport class SelectValidator\n extends Validator<string, SelectValidatorOpts, SelectValidatorMsgs> {\n\n constructor(opts?: SelectValidatorOpts, msgs?: SelectValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: string | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n options: (\"options\" in opts)\n ? opts.options!.join(\", \")\n : \"\"\n })\n : requiredMsg\n };\n }\n }\n return {\n obj: str === undefined ? null : str,\n err: \"\"\n };\n }\n\n protected objCheck(obj?: string | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"options\" in opts) {\n if (obj && opts.options!.indexOf(obj) === -1) {\n return msgs.invalid_option\n ? tpl(msgs.invalid_option,\n {\n ...opts.data,\n option: obj === null ? \"\" : obj,\n options: (\"options\" in opts)\n ? opts.options!.join(\", \")\n : \"\"\n })\n : invalidOptionMsg;\n }\n }\n return \"\";\n }\n\n protected objToStr(obj?: string | null,\n format?: string): { str: string, err: string } {\n return { str: obj || \"\", err: \"\" };\n }\n\n}\n\nexport interface StringValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n min?: number;\n max?: number;\n regexp?: RegExp;\n}\n\nexport interface StringValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nexport class StringValidator\n extends Validator<string, StringValidatorOpts, StringValidatorMsgs> {\n\n constructor(opts?: StringValidatorOpts, msgs?: StringValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: string | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n regexp: (\"regexp\" in opts)\n ? (\"\" + opts.regexp)\n : \"\"\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n if (\"regexp\" in opts) {\n if (!opts.regexp!.test(str)) {\n return {\n obj: null,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n ...opts.data,\n regexp: (\"regexp\" in opts)\n ? (\"\" + opts.regexp)\n : \"\"\n })\n : invalidFormatMsg\n };\n }\n }\n return { obj: str , err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: string | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (obj.length > opts.max!) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (obj.length < opts.min!) {\n err = true;\n }\n }\n if ((\"min\" in opts) && (\"max\" in opts)) {\n if (obj.length > opts.max! && obj.length < opts.min!) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: string | null,\n format?: string): { str: string, err: string } {\n return { str: obj || \"\", err: \"\" };\n }\n\n}\n\nexport interface NumberValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n min?: number;\n max?: number;\n strict?: boolean;\n decimals?: number;\n}\n\nexport interface NumberValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nexport class NumberValidator\n extends Validator<number, NumberValidatorOpts, NumberValidatorMsgs> {\n\n constructor(opts?: NumberValidatorOpts, msgs?: NumberValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: number | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n const n = Number(str);\n let err: boolean = false;\n if (isNaN(n)) {\n err = true;\n }\n if (opts.strict && (str !== this.objToStr(n).str)) {\n err = true;\n }\n if (err) {\n const num = isNaN(n) ? 1234.45 : n;\n return {\n obj: isNaN(n) ? null : n,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n ...opts.data,\n num: this.objToStr(num).str || \"\"\n })\n : invalidFormatMsg\n };\n }\n return { obj: n, err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: number | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (obj > opts.max!) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (obj < opts.min!) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n ...opts.data,\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: number | null,\n format?: string): { str: string, err: string } {\n let str;\n if (obj === undefined || obj === null) {\n str = \"\";\n } else {\n if (\"decimals\" in this.opts) {\n str = obj.toFixed(this.opts.decimals);\n } else {\n str = String(obj);\n }\n }\n return {\n str,\n err: \"\"\n };\n }\n\n}\n\nexport interface DateValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n min?: Date;\n max?: Date;\n dateOnly?: boolean;\n // strict?: boolean;\n\n}\n\nexport interface DateValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nconst dateToLocaleString = (date: Date) => date.toLocaleString();\nconst dateToLocaleDateString = (date: Date) => date.toLocaleDateString();\n\nexport class DateValidator\n extends Validator<Date, DateValidatorOpts, DateValidatorMsgs> {\n\n dateToStr: (date: Date) => string;\n\n constructor(opts?: DateValidatorOpts, msgs?: DateValidatorMsgs) {\n super(opts, msgs);\n this.dateToStr = opts?.dateOnly ? dateToLocaleDateString : dateToLocaleString;\n if (opts?.dateOnly && opts?.min) {\n opts.min = new Date(opts.min.getFullYear(), opts.min.getMonth(), opts.min.getDate());\n }\n if (opts?.dateOnly && opts?.max) {\n opts.max = new Date(opts.max.getFullYear(), opts.max.getMonth(), opts.max.getDate() + 1);\n }\n }\n\n protected strToObj(str?: string | null): { obj: Date | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data,\n min: (\"min\" in opts && opts.min) ? this.dateToStr(opts.min) : \"\",\n max: (\"max\" in opts && opts.max) ? this.dateToStr(opts.max) : \"\"\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n const dt = Date.parse(str);\n let d = new Date(dt);\n if (opts.dateOnly) {\n d = new Date(d.getFullYear(), d.getMonth(), d.getDate());\n }\n let err: boolean = false;\n if (isNaN(dt)) {\n err = true;\n }\n // if (opts.strict && (str !== this.objToStr(d).str)) {\n // err = true;\n // }\n if (err) {\n const date = isNaN(dt) ? new Date() : d;\n return {\n obj: isNaN(dt) ? null : d,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n ...opts.data,\n date: this.objToStr(date).str || \"\"\n })\n : invalidFormatMsg\n };\n }\n return { obj: d, err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: Date | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (opts.max && obj.getTime() > opts.max.getTime()) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (opts.min && obj < opts.min) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n ...opts.data,\n min: (\"min\" in opts && opts.min) ? this.dateToStr(opts.min) : \"\",\n max: (\"max\" in opts && opts.max) ? this.dateToStr(opts.max) : \"\"\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: Date | null,\n format?: string): { str: string, err: string } {\n return {\n str: (obj === undefined || obj === null) ? \"\" : this.dateToStr(obj),\n err: \"\"\n };\n }\n\n}\n\nexport interface BooleanValidatorOpts extends ValidatorDataOpts {\n required?: boolean;\n value?: boolean;\n}\n\nexport interface BooleanValidatorMsgs {\n required?: string;\n invalid_value?: string;\n}\n\nexport class BooleanValidator\n extends Validator<boolean, BooleanValidatorOpts, BooleanValidatorMsgs> {\n\n constructor(opts?: BooleanValidatorOpts, msgs?: BooleanValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: boolean | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n ...opts.data\n })\n : requiredMsg\n };\n }\n }\n let b;\n switch (str) {\n case \"true\":\n case \"1\":\n case \"on\":\n case \"yes\":\n b = true;\n break;\n default:\n b = false;\n }\n return { obj: b, err: \"\" };\n }\n\n protected objCheck(obj?: boolean | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n const opts = this.opts;\n const msgs = this.msgs;\n let err = false;\n if (\"value\" in opts) {\n if (obj !== opts.value) {\n err = true;\n }\n }\n if (err) {\n return msgs.invalid_value\n ? tpl(msgs.invalid_value,\n {\n ...opts.data,\n value: (\"value\" in opts) ? (\"\" + opts.value) : \"\",\n })\n : invalidValueMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: boolean | null,\n format?: string): { str: string, err: string } {\n return {\n str: (obj === undefined || obj === null) ? \"\" : (\"\" + obj),\n err: \"\"\n };\n }\n\n}\n\ntype FormValidators<TYPE> = { [key in keyof TYPE]: Validator<any, any, any> };\n\nexport type Str<TYPE> = { [key in keyof TYPE]: string };\nexport type Obj<TYPE> = { [key in keyof TYPE]: any };\nexport type Err<TYPE> = { [key in keyof TYPE]: string };\n\nexport interface FormValidatorData<TYPE> {\n str: Str<TYPE>;\n obj: Obj<TYPE>;\n err: Err<TYPE>;\n valid: boolean;\n}\n\nexport class FormValidator<TYPE extends { [key: string]: any }> {\n\n readonly validators: FormValidators<TYPE> = {} as FormValidators<TYPE>;\n\n readonly str?: Str<TYPE>;\n readonly obj?: Obj<TYPE>;\n readonly err?: Err<TYPE>;\n\n readonly valid?: boolean;\n\n addValidator(field: keyof TYPE, validator: Validator<any, any, any>): this {\n this.validators[field] = validator;\n return this;\n }\n\n validate(data: { [key in keyof TYPE]?: string }): this {\n const res = Object.keys(this.validators)\n .reduce(\n (a, k) => {\n const v = (data as any)[k];\n const r = (this.validators as any)[k].validate(v);\n (a.str as any)[k] = r.str;\n (a.obj as any)[k] = r.obj;\n (a.err as any)[k] = r.err;\n r.err && (a.valid = false);\n return a;\n },\n { str: {}, obj: {}, err: {}, valid: true });\n (this.str as any) = res.str;\n (this.obj as any) = res.obj;\n (this.err as any) = res.err;\n (this.valid as any) = res.valid;\n return this;\n }\n\n format(data: { [key in keyof TYPE]: any }): this {\n const res = Object.keys(this.validators)\n .reduce(\n (a, k) => {\n const v = (data as any)[k];\n const r = (this.validators as any)[k].format(v);\n (a.str as any)[k] = r.str;\n (a.obj as any)[k] = v;\n (a.err as any)[k] = r.err;\n r.err && (a.valid = false);\n return a;\n },\n { str: {}, obj: {}, err: {}, valid: true });\n (this.str as any) = res.str;\n (this.obj as any) = res.obj;\n (this.err as any) = res.err;\n (this.valid as any) = res.valid;\n return this;\n }\n\n data(): FormValidatorData<TYPE> {\n return {\n str: this.str!,\n obj: this.obj!,\n err: this.err!,\n valid: this.valid!\n };\n }\n\n}\n\n\n// TEST\n\n// const sv = new StringValidator(\n// {\n// required: true,\n// min: 3,\n// max: 5,\n// // regexp: /^[0123]+$/\n// data: {\n// xxx: \"xXx\"\n// }\n// },\n// {\n// required: \"required {{min}} {{max}} {{regexp}}\",\n// invalid_format: \"invalid_format {{regexp}}\",\n// not_in_range: \"not_in_range {{min}} {{max}} | data.xxx={{xxx}}\"\n// });\n\n// [\n// \"x1234\",\n// \"x1234y\",\n// \"xy\"\n// ].forEach(v => {\n// console.log();\n// console.log(v);\n// const r = sv.validate(v);\n// console.log(r);\n// if (r.obj) {\n// const f = sv.format(r.obj);\n// console.log(f);\n// }\n// });\n\n// console.log();\n\n// const nv = new NumberValidator(\n// {\n// required: true,\n// min: 3,\n// max: 500000,\n// decimals: 2,\n// strict: true\n// },\n// {\n// required: \"required {{min}} {{max}}\",\n// invalid_format: \"invalid_format {{num}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// console.log(nv.format(undefined));\n// console.log(nv.format(12345.6789));\n\n// console.log(nv.validate(\"12345.6789\"));\n// console.log(nv.validate(\"12345,6789\"));\n// console.log(nv.validate(\"12,345.6789\"));\n\n// const dv = new DateValidator(\n// {\n// required: false,\n// // min: new Date(),\n// max: new Date(),\n// clearTime: false\n// // strict: true\n// },\n// {\n// required: \"required {{min}} {{max}}\",\n// invalid_format: \"invalid_format {{date}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// console.log(dv.opts);\n\n// console.log(dv.format(undefined));\n\n// console.log(dv.format(new Date));\n\n// console.log(dv.validate(\"9/17/2020, 10:46:07 AM\"));\n// console.log(dv.format(dv.obj).str);\n// console.log(dv.validate(\"9/17/2020\"));\n// console.log(dv.format(dv.obj).str);\n// console.log(dv.validate(\"2020-09-17T08:46:07.000Z\"));\n// console.log(dv.format(dv.obj).str);\n// console.log(dv.validate(\"\"));\n// console.log(dv.format(dv.obj).str);\n\n// console.log(new Date().toString());\n// console.log(new Date().toDateString());\n// console.log(new Date().toTimeString());\n// console.log(new Date().toLocaleString());\n// console.log(new Date().toLocaleDateString());\n// console.log(new Date().toLocaleTimeString());\n// console.log();\n// console.log(new Date(Date.parse(new Date().toString())));\n// console.log(new Date(Date.parse(new Date().toDateString())));\n// console.log(new Date(Date.parse(new Date().toTimeString())));\n// console.log(new Date(Date.parse(new Date().toLocaleString())));\n// console.log(new Date(Date.parse(new Date().toLocaleDateString())));\n// console.log(new Date(Date.parse(new Date().toLocaleTimeString())));\n\n// const formData = { str: \"123a\", num: \"123456.789\", date: \"9/17/2020, 10:46:07 AM\" };\n// const formData = { str: \"\", num: \"\", date: \"\" };\n// const formData = { str: undefined, num: undefined, date: undefined };\n\n// const fv = new FormValidator<typeof formData>()\n// .addValidator(\"str\", sv)\n// .addValidator(\"num\", nv)\n// .addValidator(\"date\", dv)\n// .validate(formData);\n\n// console.log(fv.data());\n\n// fv.format(fv.obj!);\n// console.log(fv);\n\n// const ovData = { str: \"123a\", num: \"123.45\", date: \"02.01.2019 12:12\" };\n\n// const ov = new ObjectValidator<typeof ovData>()\n// .addValidator(\"str\", sv)\n// .addValidator(\"num\", nv)\n// // .addValidator(\"date\", dv)\n// .validate(ovData);\n\n// // console.log(ov);\n\n// ov.format(ov.obj!);\n// console.log(ov);\n\n// console.log();\n\n// interface ReportFormData {\n// spz: string;\n// tachometer: string;\n// dateCreated: string;\n// user: {\n// // name: string[];\n// email: string;\n// };\n// }\n\n// const dov = new ObjectValidator<ReportFormData>()\n// .addValidator(\"spz\", new StringValidator({ required: true }))\n// .addValidator(\"tachometer\", new NumberValidator({ required: true, min: 1 } ))\n// .addValidator(\"dateCreated\", new StringValidator({ required: true }))\n// .addValidator(\"user\", new ObjectValidator<ReportFormData[\"user\"]>()\n// .addValidator(\"email\", new StringValidator({ required: true}))\n// // .addValidator(\"name\", { })\n// // new ArrayValidator({\n// // required: true,\n// // validator: new StringValidator({ required: true })\n// // })\n// );\n\n// dov.validate(\n// {\n// spz: \"dasdas\",\n// tachometer: \"111222\",\n// // dateCreated: \"10.02.2019\",\n// user: {\n// // email: \"dsafasdf\",\n// }\n// },\n// {\n// dateCreated: \"01.03.2011\",\n// spz: \"32ds9f0f\",\n// tachometer: \"3213214214\",\n// user: {\n// email: \"sadmaskdmk2@dsadsamkl.com\"\n// }\n// });\n\n// const avn = new ArrayValidator<number>(new NumberValidator());\n// const rn = avn.validate([345, 123]);\n// console.log(rn);\n\n\n// interface D {\n// a: number;\n// b?: string;\n// }\n\n// const av = new ArrayValidator<T>(new ObjectValidator<T>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// );\n\n// const d: D[] = [\n// { a: 123, b: \"text\" },\n// // { a: 5.6, b: \"\" },\n// { a: 5.6 }\n// ];\n\n// const r = av.validate(d);\n// console.log(r);\n\n// const ro = new ObjectValidator<T>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// .validate({\n// a: \"5.6\",\n// b: undefined\n// // b: \"text\"\n// });\n// console.log(\"---\", ro);\n\n// const v = new StringValidator({ required: true });\n// const str = undefined;\n// const sr = v.validate(str!);\n// console.log(sr);\n\n// const v = new StringValidator({ required: true, min: 8 });\n// const str = \"\";\n// const sr = v.format(str);\n// console.log(sr, v);\n","import { Validator, tpl } from \"./validators\";\nimport * as numeral from \"numeral\";\n\nconst requiredMsg = \"required\";\nconst notInRangeMsg = \"not_in_range\";\nconst invalidFormatMsg = \"invalid_format\";\n\nconst localeDefault = \"en\";\nconst numFormatDefault = \"0,0.[00]\";\n\n\nexport interface NumeralValidatorOpts {\n required?: boolean;\n min?: number;\n max?: number;\n locale?: string;\n format?: string;\n strict?: boolean;\n}\n\nexport interface NumeralValidatorMsgs {\n required?: string;\n invalid_format?: string;\n not_in_range?: string;\n}\n\nexport class NumeralValidator\n extends Validator<Numeral, NumeralValidatorOpts, NumeralValidatorMsgs> {\n\n constructor(opts?: NumeralValidatorOpts, msgs?: NumeralValidatorMsgs) {\n super(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: Numeral | null, err: string } {\n const opts = this.opts;\n const msgs = this.msgs;\n if (\"required\" in opts) {\n if (opts.required && !str) {\n return {\n obj: null,\n err: msgs.required\n ? tpl(msgs.required,\n {\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n locale: (\"locale\" in opts)\n ? opts.locale!\n : localeDefault,\n format: (\"format\" in opts)\n ? opts.format!\n : numFormatDefault\n })\n : requiredMsg\n };\n }\n }\n if (str) {\n numeral.locale(opts.locale || localeDefault);\n const n = numeral(str);\n let err: boolean = false;\n if (n.value() === null) {\n err = true;\n }\n if (\"strict\" in opts) {\n if (opts.strict && (str !== this.objToStr(n).str)) {\n err = true;\n }\n }\n if (err) {\n const num = (n.value() !== null) ? n : numeral(1234.45);\n return {\n obj: (n.value() !== null) ? n : null,\n err: msgs.invalid_format\n ? tpl(msgs.invalid_format,\n {\n num: this.objToStr(num).str || \"\",\n locale: (\"locale\" in opts)\n ? opts.locale!\n : localeDefault,\n format: (\"format\" in opts)\n ? opts.format!\n : numFormatDefault\n })\n : invalidFormatMsg\n };\n }\n return { obj: n, err: \"\" };\n } else {\n return { obj: null, err: \"\" };\n }\n }\n\n protected objCheck(obj?: Numeral | null): string {\n if (obj === undefined || obj === null) {\n return \"\";\n }\n // if (obj.constructor === Number) {\n // obj = numeral(obj);\n // }\n const opts = this.opts;\n const msgs = this.msgs;\n let err: boolean = false;\n if (\"max\" in opts) {\n if (obj.value() > opts.max!) {\n err = true;\n }\n }\n if (\"min\" in opts) {\n if (obj.value() < opts.min!) {\n err = true;\n }\n }\n if (err) {\n return msgs.not_in_range\n ? tpl(msgs.not_in_range,\n {\n min: (\"min\" in opts) ? (\"\" + opts.min) : \"\",\n max: (\"max\" in opts) ? (\"\" + opts.max) : \"\",\n locale: (\"locale\" in opts)\n ? opts.locale!\n : localeDefault,\n format: (\"format\" in opts)\n ? opts.format!\n : numFormatDefault\n })\n : notInRangeMsg;\n }\n return \"\";\n }\n\n protected objToStr(obj?: Numeral | null,\n format?: string): { str: string, err: string } {\n // if (obj && obj.constructor === Number) {\n // obj = numeral(obj);\n // }\n numeral.locale(this.opts.locale || localeDefault);\n return {\n str: (obj === undefined || obj === null)\n ? \"\"\n : obj.format(format\n ? format\n : this.opts.format || numFormatDefault),\n err: \"\"\n };\n }\n\n}\n\nexport class NumeralNumberValidator\n extends Validator<number, NumeralValidatorOpts, NumeralValidatorMsgs> {\n\n nv: NumeralValidator;\n\n constructor(opts?: NumeralValidatorOpts, msgs?: NumeralValidatorMsgs) {\n super(opts, msgs);\n this.nv = new NumeralValidator(opts, msgs);\n }\n\n protected strToObj(str?: string | null): { obj: number | null, err: string } {\n const res = (this.nv as any).strToObj(str);\n if (res.obj) {\n res.obj = res.obj.value();\n }\n return res;\n }\n\n protected objCheck(obj?: number | null): string {\n const mObj = typeof obj === \"number\" ? numeral(obj) : obj;\n return (this.nv as any).objCheck(mObj);\n }\n\n protected objToStr(obj?: number | null,\n format?: string): { str: string, err: string } {\n const mObj = typeof obj === \"number\" ? numeral(obj) : obj;\n return (this.nv as any).objToStr(mObj, format);\n }\n\n}\n\n// TEST\n\n// import \"numeral/locales\";\n\n// // const nv = new NumeralValidator(\n// const nv = new NumeralNumberValidator(\n// {\n// required: true,\n// min: 3,\n// max: 5000,\n// locale: \"sk\",\n// format: \"0,0.0[00]\",\n// strict: true\n// },\n// {\n// required: \"required {{min}} {{max}} {{locale}} {{format}}\",\n// invalid_format: \"invalid_format {{num}} {{locale}} {{format}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// [\n// \"1234,56\",\n// \"1 234,56\",\n// \"1 234,56y\",\n// \"xy\"\n// ].forEach(v => {\n// console.log();\n// console.log(v);\n// const r = nv.validate(v);\n// console.log(r);\n// if (r.obj) {\n// const f = nv.format(r.obj);\n// console.log(f);\n// }\n// });\n","module.exports = __WEBPACK_EXTERNAL_MODULE__34__;"],"sourceRoot":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e=r();for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(window,(function(){return function(t){var r={};function e(i){if(r[i])return r[i].exports;var
|
|
1
|
+
!function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e=r();for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(window,(function(){return function(t){var r={};function e(i){if(r[i])return r[i].exports;var o=r[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=r,e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:i})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(e.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)e.d(i,o,function(r){return t[r]}.bind(null,o));return i},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=35)}({35:function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ObjectValidator=r.ArrayValidator=void 0;class i{constructor(t,r){this.validator=t,this.opts=r||{}}validate(t){this.str=[],this.obj=[],this.err=[],this.valid=!0;const r=this.validator;return r instanceof o?t.forEach(t=>{const e=r.validate(t);this.str.push(e.str),this.obj.push(e.obj),this.err.push(e.err),!e.valid&&(this.valid=!1)}):t.forEach(t=>{const e=r.validate(t);this.str.push(e.str),this.obj.push(e.obj),this.err.push(e.err),e.err&&(this.valid=!1)}),this}}r.ArrayValidator=i;class o{constructor(t){this.validators={},t&&(this.validators=t)}addValidator(t,r){return this.validators[t]=r,this}validate(t,r={}){const e=Object.assign(Object.assign({},r),t);this.valid=!0;const s=Object.keys(this.validators).reduce((t,s)=>{const a=void 0===e[s]?"":e[s],n=this.validators[s];let l;return n instanceof o?(l=n.validate(a,r[s]||{}),!l.valid&&(t.valid=!1)):n instanceof i?(l=n.validate(a),!l.valid&&(t.valid=!1)):(l=n.validate(a),l.err&&(t.valid=!1)),t.str[s]=l.str,t.obj[s]=l.obj,t.err[s]=l.err,t},{str:{},obj:{},err:{},valid:!0});return this.str=s.str,this.obj=s.obj,this.err=s.err,this.valid=s.valid,this}format(t){const r=Object.keys(this.validators).reduce((r,e)=>{const i=t[e],o=this.validators[e].format(i);return r.str[e]=o.str,r.obj[e]=i,r.err[e]=o.err,r},{str:{},obj:{},err:{},valid:!1});return r.valid=!Object.keys(r.err).filter(t=>!!r.err[t]).length,this.str=r.str,this.obj=r.obj,this.err=r.err,this.valid=r.valid,this}}r.ObjectValidator=o}})}));
|
|
2
2
|
//# sourceMappingURL=validators-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/validators-object.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ArrayValidator","validator","opts","this","data","str","obj","err","valid","ObjectValidator","forEach","validate","push","validators","field","defaults","result","keys","reduce","acc","k","undefined","res","v","format","filter","x","length"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUT,QAGnC,IAAIC,EAASM,EAAiBE,GAAY,CACzCJ,EAAGI,EACHC,GAAG,EACHV,QAAS,IAUV,OANAW,EAAQF,GAAUG,KAAKX,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOS,GAAI,EAGJT,EAAOD,QA0Df,OArDAQ,EAAoBK,EAAIF,EAGxBH,EAAoBM,EAAIP,EAGxBC,EAAoBO,EAAI,SAASf,EAASgB,EAAMC,GAC3CT,EAAoBU,EAAElB,EAASgB,IAClCG,OAAOC,eAAepB,EAASgB,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhET,EAAoBe,EAAI,SAASvB,GACX,oBAAXwB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAepB,EAASwB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAepB,EAAS,aAAc,CAAE0B,OAAO,KAQvDlB,EAAoBmB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQlB,EAAoBkB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFAvB,EAAoBe,EAAEO,GACtBX,OAAO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E4C,IAAYa,GAAKtC,EAAEyB,IACf5C,GAEX,CAAE0C,IAAK,GAAIC,IAAK,GAAIC,IAAK,GAAIC,OAAO,IAQ5C,OAPAc,EAAId,OAAS9B,OACRuC,KAAKK,EAAIf,KACTkB,OAAOC,KAAQJ,EAAIf,IAAYmB,IAAIC,OACvCxB,KAAKE,IAAciB,EAAIjB,IACvBF,KAAKG,IAAcgB,EAAIhB,IACvBH,KAAKI,IAAce,EAAIf,IACvBJ,KAAKK,MAAgBc,EAAId,MACnBL,MA/Ef","file":"validators-object.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 35);\n","import { Validator } from \"./validators\";\n\ntype StrDict<OBJ, Optional extends (true | false) = false> = {\n 0: string,\n 1: string[],\n 2: Optional extends true\n ? { [prop in keyof OBJ]+?: StrDict<OBJ[prop], true> }\n : { [prop in keyof OBJ]: StrDict<OBJ[prop], false> }\n}[OBJ extends (string | number | boolean)\n ? 0\n : OBJ extends string[]\n ? 1\n : OBJ extends { [prop: string]: any }\n ? 2\n : never];\n\nexport interface ArrayValidatorOpts {\n required?: boolean;\n min?: number;\n max?: number;\n}\n\nexport interface ArrayValidatorMsgs {\n required?: string;\n not_in_range?: string;\n invalid_format?: string;\n}\n\nexport class ArrayValidator<TYPE = any> {\n\n readonly validator: Validator<TYPE, any, any> | ObjectValidator<TYPE>;\n readonly opts: ArrayValidatorOpts;\n\n readonly str?: string[] | StrDict<TYPE>[];\n readonly obj?: TYPE[] | { [key in keyof TYPE]: any }[];\n readonly err?: string[] | StrDict<TYPE>[];\n\n readonly valid?: boolean;\n\n constructor(validator: Validator<TYPE, any, any> | ObjectValidator<TYPE>,\n opts?: ArrayValidatorOpts) {\n this.validator = validator;\n this.opts = opts || {};\n }\n\n validate(data: string[] | TYPE[]): this {\n (this.str as any) = [];\n (this.obj as any) = [];\n (this.err as any) = [];\n (this.valid as any) = true;\n\n const validator = this.validator;\n\n if (validator instanceof ObjectValidator) {\n (data as any).forEach((d: any) => {\n const r = (validator as ObjectValidator<TYPE>).validate(d);\n (this.str as StrDict<TYPE>[]).push(r.str!);\n (this.obj as { [key in keyof TYPE]: any }[]).push(r.obj!);\n (this.err as StrDict<TYPE>[]).push(r.err!);\n !r.valid && ((this.valid as any) = false);\n });\n } else { // Validator<T, any, any>\n (data as any).forEach((d: any) => {\n const r = (validator as Validator<TYPE, any, any>).validate(d);\n this.str!.push(r.str as any);\n this.obj!.push(r.obj!);\n this.err!.push(r.err as any);\n r.err && ((this.valid as any) = false);\n });\n }\n return this;\n }\n\n}\n\ntype ObjectValidators<TYPE> = {\n [key in keyof TYPE]?: Validator<any, any, any> |\n ObjectValidator<any> |\n ArrayValidator<any> };\n\nexport class ObjectValidator<TYPE = any> {\n\n readonly validators: ObjectValidators<TYPE> = {} as any;\n\n readonly str?: StrDict<TYPE>;\n readonly obj?: { [key in keyof TYPE]: any };\n readonly err?: StrDict<TYPE>;\n\n readonly valid?: boolean;\n\n constructor(validators?: ObjectValidators<TYPE>) {\n if (validators) {\n this.validators = validators;\n }\n }\n\n addValidator(field: keyof TYPE,\n validator: Validator<any, any, any>\n | ObjectValidator<any>\n | ArrayValidator<any>): this {\n this.validators[field] = validator;\n return this;\n }\n\n validate(data: StrDict<TYPE, true>,\n defaults: StrDict<TYPE> = {} as any): this {\n const d = { ...defaults as object, ...data as object };\n (this as any).valid = true;\n const result = Object.keys(this.validators)\n .reduce(\n (acc, k) => {\n const value = (d as any)[k] === undefined ? \"\" : (d as any)[k];\n const validator = (this.validators as any)[k];\n\n let res: any;\n if (validator instanceof ObjectValidator) {\n res = validator.validate(value, (defaults as any)[k] || {});\n !res.valid && (acc.valid = false);\n } else if (validator instanceof ArrayValidator) {\n res = validator.validate(value);\n !res.valid && (acc.valid = false);\n } else {\n res = validator.validate(value);\n res.err && (acc.valid = false);\n }\n\n (acc.str as any)[k] = res.str;\n (acc.obj as any)[k] = res.obj;\n (acc.err as any)[k] = res.err;\n return acc;\n },\n { str: {}, obj: {}, err: {}, valid: true });\n\n (this.str as any) = result.str;\n (this.obj as any) = result.obj;\n (this.err as any) = result.err;\n (this.valid as any) = result.valid;\n return this;\n }\n\n format(data: { [key in keyof TYPE]: any }): this {\n const res = Object.keys(this.validators)\n .reduce(\n (a, k) => {\n const v = (data as any)[k];\n const r = (this.validators as any)[k].format(v);\n (a.str as any)[k] = r.str;\n (a.obj as any)[k] = v;\n (a.err as any)[k] = r.err;\n return a;\n },\n { str: {}, obj: {}, err: {}, valid: false });\n res.valid = !Object\n .keys(res.err)\n .filter(x => !!(res.err as any)[x]).length;\n (this.str as any) = res.str;\n (this.obj as any) = res.obj;\n (this.err as any) = res.err;\n (this.valid as any) = res.valid;\n return this;\n }\n\n}\n\n// const sv = new StringValidator(\n// {\n// required: true,\n// min: 3,\n// max: 5\n// // regexp: /^[0123]+$/\n// },\n// {\n// required: \"required {{min}} {{max}} {{regexp}}\",\n// invalid_format: \"invalid_format {{regexp}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// [\n// \"x1234\",\n// \"x1234y\",\n// \"xy\"\n// ].forEach(v => {\n// console.log();\n// console.log(v);\n// const r = sv.validate(v);\n// console.log(r);\n// if (r.obj) {\n// const f = sv.format(r.obj);\n// console.log(f);\n// }\n// });\n\n// console.log();\n\n// const nv = new NumberValidator(\n// {\n// required: true,\n// min: 3,\n// max: 500000\n// },\n// {\n// required: \"required {{min}} {{max}}\",\n// invalid_format: \"invalid_format {{num}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// const ovData = { str: \"123a\", num: \"123.45\", date: \"02.01.2019 12:12\" };\n\n// const ov = new ObjectValidator<typeof ovData>()\n// .addValidator(\"str\", sv)\n// .addValidator(\"num\", nv)\n// // .addValidator(\"date\", dv)\n// .validate(ovData);\n\n// // console.log(ov);\n\n// ov.format(ov.obj!);\n// console.log(ov);\n\n// console.log();\n\n// interface ReportFormData {\n// spz: string;\n// tachometer: string;\n// dateCreated: string;\n// user: {\n// // name: string[];\n// email: string;\n// };\n// }\n\n// const dov = new ObjectValidator<ReportFormData>()\n// .addValidator(\"spz\", new StringValidator({ required: true }))\n// .addValidator(\"tachometer\", new NumberValidator({ required: true, min: 1 } ))\n// .addValidator(\"dateCreated\", new StringValidator({ required: true }))\n// .addValidator(\"user\", new ObjectValidator<ReportFormData[\"user\"]>()\n// .addValidator(\"email\", new StringValidator({ required: true}))\n// // .addValidator(\"name\", { })\n// // new ArrayValidator({\n// // required: true,\n// // validator: new StringValidator({ required: true })\n// // })\n// );\n\n// dov.validate(\n// {\n// spz: \"dasdas\",\n// tachometer: \"111222\",\n// // dateCreated: \"10.02.2019\",\n// user: {\n// // email: \"dsafasdf\",\n// }\n// },\n// {\n// dateCreated: \"01.03.2011\",\n// spz: \"32ds9f0f\",\n// tachometer: \"3213214214\",\n// user: {\n// email: \"sadmaskdmk2@dsadsamkl.com\"\n// }\n// });\n\n// const avn = new ArrayValidator<number>(new NumberValidator());\n// const rn = avn.validate([345, 123]);\n// console.log(rn);\n\n\n// interface D {\n// a: number;\n// b?: string;\n// }\n\n// const av = new ArrayValidator<D>(new ObjectValidator<D>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// );\n\n// const d: D[] = [\n// { a: 123, b: \"text\" },\n// // { a: 5.6, b: \"\" },\n// { a: 5.6 }\n// ];\n\n// const r = av.validate(d);\n// console.log(r);\n\n// const ro = new ObjectValidator<D>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// .validate({\n// a: \"5.6\",\n// b: undefined\n// // b: \"text\"\n// });\n// console.log(\"---\", ro);\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/validators-object.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ArrayValidator","validator","opts","this","data","str","obj","err","valid","ObjectValidator","forEach","validate","push","validators","field","defaults","result","keys","reduce","acc","k","undefined","res","v","format","filter","x","length"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUT,QAGnC,IAAIC,EAASM,EAAiBE,GAAY,CACzCJ,EAAGI,EACHC,GAAG,EACHV,QAAS,IAUV,OANAW,EAAQF,GAAUG,KAAKX,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOS,GAAI,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EAAMrB,EAAUU,SAAS1B,GACzBqC,EAAIf,MAAQY,EAAIX,OAAQ,IAG3BW,EAAId,IAAYe,GAAKE,EAAIjB,IACzBc,EAAIb,IAAYc,GAAKE,EAAIhB,IACzBa,EAAIZ,IAAYa,GAAKE,EAAIf,IACnBY,GAEX,CAAEd,IAAK,GAAIC,IAAK,GAAIC,IAAK,GAAIC,OAAO,IAM5C,OAJCL,KAAKE,IAAcW,EAAOX,IAC1BF,KAAKG,IAAcU,EAAOV,IAC1BH,KAAKI,IAAcS,EAAOT,IAC1BJ,KAAKK,MAAgBQ,EAAOR,MACtBL,KAGX,OAAOC,GACH,MAAMkB,EAAM5C,OAAOuC,KAAKd,KAAKU,YACxBK,OACG,CAACvD,EAAGyD,KACA,MAAMG,EAAKnB,EAAagB,GAClBtC,EAAKqB,KAAKU,WAAmBO,GAAGI,OAAOD,GAI7C,OAHC5D,EAAE0C,IAAYe,GAAKtC,EAAEuB,IACrB1C,EAAE2C,IAAYc,GAAKG,EACnB5D,EAAE4C,IAAYa,GAAKtC,EAAEyB,IACf5C,GAEX,CAAE0C,IAAK,GAAIC,IAAK,GAAIC,IAAK,GAAIC,OAAO,IAQ5C,OAPAc,EAAId,OAAS9B,OACRuC,KAAKK,EAAIf,KACTkB,OAAOC,KAAQJ,EAAIf,IAAYmB,IAAIC,OACvCxB,KAAKE,IAAciB,EAAIjB,IACvBF,KAAKG,IAAcgB,EAAIhB,IACvBH,KAAKI,IAAce,EAAIf,IACvBJ,KAAKK,MAAgBc,EAAId,MACnBL,MA/Ef","file":"validators-object.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 35);\n","import { Validator } from \"./validators\";\n\ntype StrDict<OBJ, Optional extends (true | false) = false> = {\n 0: string,\n 1: string[],\n 2: Optional extends true\n ? { [prop in keyof OBJ]+?: StrDict<OBJ[prop], true> }\n : { [prop in keyof OBJ]: StrDict<OBJ[prop], false> }\n}[OBJ extends (string | number | boolean)\n ? 0\n : OBJ extends string[]\n ? 1\n : OBJ extends { [prop: string]: any }\n ? 2\n : never];\n\nexport interface ArrayValidatorOpts {\n required?: boolean;\n min?: number;\n max?: number;\n}\n\nexport interface ArrayValidatorMsgs {\n required?: string;\n not_in_range?: string;\n invalid_format?: string;\n}\n\nexport class ArrayValidator<TYPE = any> {\n\n readonly validator: Validator<TYPE, any, any> | ObjectValidator<TYPE>;\n readonly opts: ArrayValidatorOpts;\n\n readonly str?: string[] | StrDict<TYPE>[];\n readonly obj?: TYPE[] | { [key in keyof TYPE]: any }[];\n readonly err?: string[] | StrDict<TYPE>[];\n\n readonly valid?: boolean;\n\n constructor(validator: Validator<TYPE, any, any> | ObjectValidator<TYPE>,\n opts?: ArrayValidatorOpts) {\n this.validator = validator;\n this.opts = opts || {};\n }\n\n validate(data: string[] | TYPE[]): this {\n (this.str as any) = [];\n (this.obj as any) = [];\n (this.err as any) = [];\n (this.valid as any) = true;\n\n const validator = this.validator;\n\n if (validator instanceof ObjectValidator) {\n (data as any).forEach((d: any) => {\n const r = (validator as ObjectValidator<TYPE>).validate(d);\n (this.str as StrDict<TYPE>[]).push(r.str!);\n (this.obj as { [key in keyof TYPE]: any }[]).push(r.obj!);\n (this.err as StrDict<TYPE>[]).push(r.err!);\n !r.valid && ((this.valid as any) = false);\n });\n } else { // Validator<T, any, any>\n (data as any).forEach((d: any) => {\n const r = (validator as Validator<TYPE, any, any>).validate(d);\n this.str!.push(r.str as any);\n this.obj!.push(r.obj!);\n this.err!.push(r.err as any);\n r.err && ((this.valid as any) = false);\n });\n }\n return this;\n }\n\n}\n\ntype ObjectValidators<TYPE> = {\n [key in keyof TYPE]?: Validator<any, any, any> |\n ObjectValidator<any> |\n ArrayValidator<any> };\n\nexport class ObjectValidator<TYPE = any> {\n\n readonly validators: ObjectValidators<TYPE> = {} as any;\n\n readonly str?: StrDict<TYPE>;\n readonly obj?: { [key in keyof TYPE]: any };\n readonly err?: StrDict<TYPE>;\n\n readonly valid?: boolean;\n\n constructor(validators?: ObjectValidators<TYPE>) {\n if (validators) {\n this.validators = validators;\n }\n }\n\n addValidator(field: keyof TYPE,\n validator: Validator<any, any, any>\n | ObjectValidator<any>\n | ArrayValidator<any>): this {\n this.validators[field] = validator;\n return this;\n }\n\n validate(data: StrDict<TYPE, true>,\n defaults: StrDict<TYPE> = {} as any): this {\n const d = { ...defaults as object, ...data as object };\n (this as any).valid = true;\n const result = Object.keys(this.validators)\n .reduce(\n (acc, k) => {\n const value = (d as any)[k] === undefined ? \"\" : (d as any)[k];\n const validator = (this.validators as any)[k];\n\n let res: any;\n if (validator instanceof ObjectValidator) {\n res = validator.validate(value, (defaults as any)[k] || {});\n !res.valid && (acc.valid = false);\n } else if (validator instanceof ArrayValidator) {\n res = validator.validate(value);\n !res.valid && (acc.valid = false);\n } else {\n res = validator.validate(value);\n res.err && (acc.valid = false);\n }\n\n (acc.str as any)[k] = res.str;\n (acc.obj as any)[k] = res.obj;\n (acc.err as any)[k] = res.err;\n return acc;\n },\n { str: {}, obj: {}, err: {}, valid: true });\n\n (this.str as any) = result.str;\n (this.obj as any) = result.obj;\n (this.err as any) = result.err;\n (this.valid as any) = result.valid;\n return this;\n }\n\n format(data: { [key in keyof TYPE]: any }): this {\n const res = Object.keys(this.validators)\n .reduce(\n (a, k) => {\n const v = (data as any)[k];\n const r = (this.validators as any)[k].format(v);\n (a.str as any)[k] = r.str;\n (a.obj as any)[k] = v;\n (a.err as any)[k] = r.err;\n return a;\n },\n { str: {}, obj: {}, err: {}, valid: false });\n res.valid = !Object\n .keys(res.err)\n .filter(x => !!(res.err as any)[x]).length;\n (this.str as any) = res.str;\n (this.obj as any) = res.obj;\n (this.err as any) = res.err;\n (this.valid as any) = res.valid;\n return this;\n }\n\n}\n\n// const sv = new StringValidator(\n// {\n// required: true,\n// min: 3,\n// max: 5\n// // regexp: /^[0123]+$/\n// },\n// {\n// required: \"required {{min}} {{max}} {{regexp}}\",\n// invalid_format: \"invalid_format {{regexp}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// [\n// \"x1234\",\n// \"x1234y\",\n// \"xy\"\n// ].forEach(v => {\n// console.log();\n// console.log(v);\n// const r = sv.validate(v);\n// console.log(r);\n// if (r.obj) {\n// const f = sv.format(r.obj);\n// console.log(f);\n// }\n// });\n\n// console.log();\n\n// const nv = new NumberValidator(\n// {\n// required: true,\n// min: 3,\n// max: 500000\n// },\n// {\n// required: \"required {{min}} {{max}}\",\n// invalid_format: \"invalid_format {{num}}\",\n// not_in_range: \"not_in_range {{min}} {{max}}\"\n// });\n\n// const ovData = { str: \"123a\", num: \"123.45\", date: \"02.01.2019 12:12\" };\n\n// const ov = new ObjectValidator<typeof ovData>()\n// .addValidator(\"str\", sv)\n// .addValidator(\"num\", nv)\n// // .addValidator(\"date\", dv)\n// .validate(ovData);\n\n// // console.log(ov);\n\n// ov.format(ov.obj!);\n// console.log(ov);\n\n// console.log();\n\n// interface ReportFormData {\n// spz: string;\n// tachometer: string;\n// dateCreated: string;\n// user: {\n// // name: string[];\n// email: string;\n// };\n// }\n\n// const dov = new ObjectValidator<ReportFormData>()\n// .addValidator(\"spz\", new StringValidator({ required: true }))\n// .addValidator(\"tachometer\", new NumberValidator({ required: true, min: 1 } ))\n// .addValidator(\"dateCreated\", new StringValidator({ required: true }))\n// .addValidator(\"user\", new ObjectValidator<ReportFormData[\"user\"]>()\n// .addValidator(\"email\", new StringValidator({ required: true}))\n// // .addValidator(\"name\", { })\n// // new ArrayValidator({\n// // required: true,\n// // validator: new StringValidator({ required: true })\n// // })\n// );\n\n// dov.validate(\n// {\n// spz: \"dasdas\",\n// tachometer: \"111222\",\n// // dateCreated: \"10.02.2019\",\n// user: {\n// // email: \"dsafasdf\",\n// }\n// },\n// {\n// dateCreated: \"01.03.2011\",\n// spz: \"32ds9f0f\",\n// tachometer: \"3213214214\",\n// user: {\n// email: \"sadmaskdmk2@dsadsamkl.com\"\n// }\n// });\n\n// const avn = new ArrayValidator<number>(new NumberValidator());\n// const rn = avn.validate([345, 123]);\n// console.log(rn);\n\n\n// interface D {\n// a: number;\n// b?: string;\n// }\n\n// const av = new ArrayValidator<D>(new ObjectValidator<D>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// );\n\n// const d: D[] = [\n// { a: 123, b: \"text\" },\n// // { a: 5.6, b: \"\" },\n// { a: 5.6 }\n// ];\n\n// const r = av.validate(d);\n// console.log(r);\n\n// const ro = new ObjectValidator<D>()\n// .addValidator(\"a\", new NumberValidator())\n// .addValidator(\"b\", new StringValidator({ required: true }))\n// .validate({\n// a: \"5.6\",\n// b: undefined\n// // b: \"text\"\n// });\n// console.log(\"---\", ro);\n"],"sourceRoot":""}
|
package/dist/umd/validators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e=r();for(var
|
|
1
|
+
!function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e=r();for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(window,(function(){return function(t){var r={};function e(i){if(r[i])return r[i].exports;var n=r[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,e),n.l=!0,n.exports}return e.m=t,e.c=r,e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:i})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(e.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var n in t)e.d(i,n,function(r){return t[r]}.bind(null,n));return i},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=3)}({3:function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FormValidator=r.BooleanValidator=r.DateValidator=r.NumberValidator=r.StringValidator=r.SelectValidator=r.tpl=r.Validator=r.rodneCisloRgex=r.pscRgex=r.phoneRgex=r.emailRegex=void 0;r.emailRegex=/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/,r.phoneRgex=/^(((00)([- ]?)|\+)(\d{1,3})([- ]?))?((\d{3})([- ]?))((\d{3})([- ]?))(\d{3})$/,r.pscRgex=/^\d{3} ?\d{2}$/,r.rodneCisloRgex=/^\s*(\d\d)(\d\d)(\d\d)[ /]*(\d\d\d)(\d?)\s*$/;class i{constructor(t,r){this.str=null,this.err=null,this.obj=null,this.opts=t||{},this.msgs=r||{}}validate(t){if("string"==typeof t||null==t){const r=t;this.str=r;const e=this.strToObj(r);if(this.obj=e.obj,e.err)return this.err=e.err,{str:null==r?"":r,obj:e.obj,err:e.err};const i=this.objCheck(e.obj);return this.err=i,{str:null==r?"":r,obj:e.obj,err:i}}{this.str=null==t?null:""+t;const r=this.objCheck(t);return this.err=r,{str:this.str,obj:t,err:r}}}format(t,r){const e=this.objToStr(t,r);return{str:void 0===e.str||null===e.str?"":e.str,err:e.err}}}function n(t,r){return Object.keys(r).map(t=>[t,r[t]]).reduce((t,r)=>t.replace(new RegExp(`\\{\\{${r[0]}\\}\\}`,"g"),String(r[1])),t)}r.Validator=i,r.tpl=n;r.SelectValidator=class extends i{constructor(t,r){super(t,r)}strToObj(t){const r=this.opts,e=this.msgs;return"required"in r&&r.required&&!t?{obj:null,err:e.required?n(e.required,Object.assign(Object.assign({},r.data),{options:"options"in r?r.options.join(", "):""})):"required"}:{obj:void 0===t?null:t,err:""}}objCheck(t){if(null==t)return"";const r=this.opts,e=this.msgs;return"options"in r&&t&&-1===r.options.indexOf(t)?e.invalid_option?n(e.invalid_option,Object.assign(Object.assign({},r.data),{option:null===t?"":t,options:"options"in r?r.options.join(", "):""})):"invalid_option":""}objToStr(t,r){return{str:t||"",err:""}}};r.StringValidator=class extends i{constructor(t,r){super(t,r)}strToObj(t){const r=this.opts,e=this.msgs;return"required"in r&&r.required&&!t?{obj:null,err:e.required?n(e.required,Object.assign(Object.assign({},r.data),{min:"min"in r?""+r.min:"",max:"max"in r?""+r.max:"",regexp:"regexp"in r?""+r.regexp:""})):"required"}:t?"regexp"in r&&!r.regexp.test(t)?{obj:null,err:e.invalid_format?n(e.invalid_format,Object.assign(Object.assign({},r.data),{regexp:"regexp"in r?""+r.regexp:""})):"invalid_format"}:{obj:t,err:""}:{obj:null,err:""}}objCheck(t){if(null==t)return"";const r=this.opts,e=this.msgs;let i=!1;return"max"in r&&t.length>r.max&&(i=!0),"min"in r&&t.length<r.min&&(i=!0),"min"in r&&"max"in r&&t.length>r.max&&t.length<r.min&&(i=!0),i?e.not_in_range?n(e.not_in_range,Object.assign(Object.assign({},r.data),{min:"min"in r?""+r.min:"",max:"max"in r?""+r.max:""})):"not_in_range":""}objToStr(t,r){return{str:t||"",err:""}}};r.NumberValidator=class extends i{constructor(t,r){super(t,r)}strToObj(t){const r=this.opts,e=this.msgs;if("required"in r&&r.required&&!t)return{obj:null,err:e.required?n(e.required,Object.assign(Object.assign({},r.data),{min:"min"in r?""+r.min:"",max:"max"in r?""+r.max:""})):"required"};if(t){const i=Number(t);let s=!1;if(isNaN(i)&&(s=!0),r.strict&&t!==this.objToStr(i).str&&(s=!0),s){const t=isNaN(i)?1234.45:i;return{obj:isNaN(i)?null:i,err:e.invalid_format?n(e.invalid_format,Object.assign(Object.assign({},r.data),{num:this.objToStr(t).str||""})):"invalid_format"}}return{obj:i,err:""}}return{obj:null,err:""}}objCheck(t){if(null==t)return"";const r=this.opts,e=this.msgs;let i=!1;return"max"in r&&t>r.max&&(i=!0),"min"in r&&t<r.min&&(i=!0),i?e.not_in_range?n(e.not_in_range,Object.assign(Object.assign({},r.data),{min:"min"in r?""+r.min:"",max:"max"in r?""+r.max:""})):"not_in_range":""}objToStr(t,r){let e;return e=null==t?"":"decimals"in this.opts?t.toFixed(this.opts.decimals):String(t),{str:e,err:""}}};const s=t=>t.toLocaleString(),o=t=>t.toLocaleDateString();r.DateValidator=class extends i{constructor(t,r){super(t,r),this.dateToStr=(null==t?void 0:t.dateOnly)?o:s,(null==t?void 0:t.dateOnly)&&(null==t?void 0:t.min)&&(t.min=new Date(t.min.getFullYear(),t.min.getMonth(),t.min.getDate())),(null==t?void 0:t.dateOnly)&&(null==t?void 0:t.max)&&(t.max=new Date(t.max.getFullYear(),t.max.getMonth(),t.max.getDate()+1))}strToObj(t){const r=this.opts,e=this.msgs;if("required"in r&&r.required&&!t)return{obj:null,err:e.required?n(e.required,Object.assign(Object.assign({},r.data),{min:"min"in r&&r.min?this.dateToStr(r.min):"",max:"max"in r&&r.max?this.dateToStr(r.max):""})):"required"};if(t){const i=Date.parse(t);let s=new Date(i);r.dateOnly&&(s=new Date(s.getFullYear(),s.getMonth(),s.getDate()));let o=!1;if(isNaN(i)&&(o=!0),o){const t=isNaN(i)?new Date:s;return{obj:isNaN(i)?null:s,err:e.invalid_format?n(e.invalid_format,Object.assign(Object.assign({},r.data),{date:this.objToStr(t).str||""})):"invalid_format"}}return{obj:s,err:""}}return{obj:null,err:""}}objCheck(t){if(null==t)return"";const r=this.opts,e=this.msgs;let i=!1;return"max"in r&&r.max&&t.getTime()>r.max.getTime()&&(i=!0),"min"in r&&r.min&&t<r.min&&(i=!0),i?e.not_in_range?n(e.not_in_range,Object.assign(Object.assign({},r.data),{min:"min"in r&&r.min?this.dateToStr(r.min):"",max:"max"in r&&r.max?this.dateToStr(r.max):""})):"not_in_range":""}objToStr(t,r){return{str:null==t?"":this.dateToStr(t),err:""}}};r.BooleanValidator=class extends i{constructor(t,r){super(t,r)}strToObj(t){const r=this.opts,e=this.msgs;if("required"in r&&r.required&&!t)return{obj:null,err:e.required?n(e.required,Object.assign({},r.data)):"required"};let i;switch(t){case"true":case"1":case"on":case"yes":i=!0;break;default:i=!1}return{obj:i,err:""}}objCheck(t){if(null==t)return"";const r=this.opts,e=this.msgs;let i=!1;return"value"in r&&t!==r.value&&(i=!0),i?e.invalid_value?n(e.invalid_value,Object.assign(Object.assign({},r.data),{value:"value"in r?""+r.value:""})):"invalid_value":""}objToStr(t,r){return{str:null==t?"":""+t,err:""}}};r.FormValidator=class{constructor(){this.validators={}}addValidator(t,r){return this.validators[t]=r,this}validate(t){const r=Object.keys(this.validators).reduce((r,e)=>{const i=t[e],n=this.validators[e].validate(i);return r.str[e]=n.str,r.obj[e]=n.obj,r.err[e]=n.err,n.err&&(r.valid=!1),r},{str:{},obj:{},err:{},valid:!0});return this.str=r.str,this.obj=r.obj,this.err=r.err,this.valid=r.valid,this}format(t){const r=Object.keys(this.validators).reduce((r,e)=>{const i=t[e],n=this.validators[e].format(i);return r.str[e]=n.str,r.obj[e]=i,r.err[e]=n.err,n.err&&(r.valid=!1),r},{str:{},obj:{},err:{},valid:!0});return this.str=r.str,this.obj=r.obj,this.err=r.err,this.valid=r.valid,this}data(){return{str:this.str,obj:this.obj,err:this.err,valid:this.valid}}}}})}));
|
|
2
2
|
//# sourceMappingURL=validators.js.map
|