@epilot/validators
Advanced tools
+7
-0
@@ -5,2 +5,9 @@ # Changelog | ||
| ### [0.0.5](https://gitlab.com/e-pilot/product/frontend/base/validators/compare/v0.0.4...v0.0.5) (2021-03-16) | ||
| ### Bug Fixes | ||
| * validators type ([85f75d4](https://gitlab.com/e-pilot/product/frontend/base/validators/commit/85f75d4113b3c06170bea6462d52a2f21a73dc12)) | ||
| ### [0.0.4](https://gitlab.com/e-pilot/product/frontend/base/validators/compare/v0.0.3...v0.0.4) (2021-03-16) | ||
@@ -7,0 +14,0 @@ |
@@ -7,7 +7,9 @@ /** | ||
| export declare function validateBirthDate(data: string): boolean; | ||
| export declare const functionalValidators: { | ||
| birth_date: { | ||
| declare type FunctionalValidators = { | ||
| [key: string]: { | ||
| name: string; | ||
| callback: typeof validateBirthDate; | ||
| callback: (data: string) => boolean; | ||
| }; | ||
| }; | ||
| export declare const functionalValidators: FunctionalValidators; | ||
| export {}; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"validators.cjs.development.js","sources":["../src/utils/reg_exps.ts","../src/utils/validators.ts"],"sourcesContent":["type RegExpStatment = {\n [key: string]: {\n name: string\n regex: RegExp\n description: string\n }\n}\n\nconst regExpStatments: RegExpStatment = {\n email: {\n name: 'email',\n regex: /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n description: 'this pattern is used to check if the email is valid'\n },\n\n lettersMinimum_3: {\n name: 'lettersMinimum_3',\n regex: /^[a-zA-Z]{3,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 3 letter'\n },\n\n numbersMinimum_6: {\n name: 'numbersMinimum_6',\n regex: /^[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers'\n },\n\n numbersTelephone_6: {\n name: 'numbersTelephone_6',\n regex: /^[+]*[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign'\n },\n\n numbersExact_11: {\n name: 'numbersExact_11',\n regex: /^[0-9]{11,11}$/,\n description:\n 'this pattern is used to validate that the input length exactly 12 numbers'\n },\n\n numbersMaximum_11: {\n name: 'numbersMaximum_11',\n regex: /^[0-9]{1,11}$/,\n description:\n 'this pattern is used to validate that the input length is maximum 11 numbers'\n },\n\n /***\n * this is only valid for Germany\n */\n iban: {\n name: 'iban',\n regex: /^[a-zA-Z]{2}[0-9]{20}$/,\n description:\n 'this pattern is used to validate that the input is iban (2 letters followed by exactly 20 numbers)'\n },\n\n date_de: {\n name: 'date_de',\n regex: /^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,\n description:\n 'this pattern is used to validate that the input is valid german date DD.MM.YYY'\n }\n}\n\nexport default regExpStatments\n","import regExpStatments from './reg_exps'\n\n/**\n * Validate date in german format is in the past\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateBirthDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format and the date in the past\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()) {\n return true\n }\n }\n\n return false\n}\n\nfunction parseDateDE(dateStr: string) {\n const dateArray = dateStr.split('.')\n const date = new Date()\n\n date.setFullYear(+dateArray[2], +dateArray[1] - 1, +dateArray[0])\n\n return date\n}\n\nexport const functionalValidators = {\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate\n }\n}\n"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","iban","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","dateStr","dateArray","split","date","setFullYear","functionalValidators","birth_date","callback"],"mappings":";;;;AAQA,IAAMA,eAAe,GAAmB;AACtCC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI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,IAAD,CAAX,CAAkBI,OAAlB,KAA8B,IAAIC,IAAJ,GAAWD,OAAX,EAAlC,EAAwD;AACtD,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD;;AAED,SAASD,WAAT,CAAqBG,OAArB;AACE,MAAMC,SAAS,GAAGD,OAAO,CAACE,KAAR,CAAc,GAAd,CAAlB;AACA,MAAMC,IAAI,GAAG,IAAIJ,IAAJ,EAAb;AAEAI,EAAAA,IAAI,CAACC,WAAL,CAAiB,CAACH,SAAS,CAAC,CAAD,CAA3B,EAAgC,CAACA,SAAS,CAAC,CAAD,CAAV,GAAgB,CAAhD,EAAmD,CAACA,SAAS,CAAC,CAAD,CAA7D;AAEA,SAAOE,IAAP;AACD;;AAED,IAAaE,oBAAoB,GAAG;AAClCC,EAAAA,UAAU,EAAE;AACVvB,IAAAA,IAAI,EAAE,YADI;AAEVwB,IAAAA,QAAQ,EAAEd;AAFA;AADsB,CAA7B;;;;;;"} | ||
| {"version":3,"file":"validators.cjs.development.js","sources":["../src/utils/reg_exps.ts","../src/utils/validators.ts"],"sourcesContent":["type RegExpStatment = {\n [key: string]: {\n name: string\n regex: RegExp\n description: string\n }\n}\n\nconst regExpStatments: RegExpStatment = {\n email: {\n name: 'email',\n regex: /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n description: 'this pattern is used to check if the email is valid'\n },\n\n lettersMinimum_3: {\n name: 'lettersMinimum_3',\n regex: /^[a-zA-Z]{3,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 3 letter'\n },\n\n numbersMinimum_6: {\n name: 'numbersMinimum_6',\n regex: /^[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers'\n },\n\n numbersTelephone_6: {\n name: 'numbersTelephone_6',\n regex: /^[+]*[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign'\n },\n\n numbersExact_11: {\n name: 'numbersExact_11',\n regex: /^[0-9]{11,11}$/,\n description:\n 'this pattern is used to validate that the input length exactly 12 numbers'\n },\n\n numbersMaximum_11: {\n name: 'numbersMaximum_11',\n regex: /^[0-9]{1,11}$/,\n description:\n 'this pattern is used to validate that the input length is maximum 11 numbers'\n },\n\n /***\n * this is only valid for Germany\n */\n iban: {\n name: 'iban',\n regex: /^[a-zA-Z]{2}[0-9]{20}$/,\n description:\n 'this pattern is used to validate that the input is iban (2 letters followed by exactly 20 numbers)'\n },\n\n date_de: {\n name: 'date_de',\n regex: /^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,\n description:\n 'this pattern is used to validate that the input is valid german date DD.MM.YYY'\n }\n}\n\nexport default regExpStatments\n","import regExpStatments from './reg_exps'\n\n/**\n * Validate date in german format is in the past\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateBirthDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format and the date in the past\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()) {\n return true\n }\n }\n\n return false\n}\n\nfunction parseDateDE(dateStr: string) {\n const dateArray = dateStr.split('.')\n const date = new Date()\n\n date.setFullYear(+dateArray[2], +dateArray[1] - 1, +dateArray[0])\n\n return date\n}\n\ntype FunctionalValidators = {\n [key: string]: {\n name: string\n callback: (data: string) => boolean\n }\n}\n\nexport const functionalValidators: FunctionalValidators = {\n\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate\n }\n}\n"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","iban","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","dateStr","dateArray","split","date","setFullYear","functionalValidators","birth_date","callback"],"mappings":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AAIW,OAAO,CAACC,IAAR,CAAaF,IAAb,CAAJ,EAAwB;AACtB,QAAIG,WAAW,CAACH,IAAD,CAAX,CAAkBI,OAAlB,KAA8B,IAAIC,IAAJ,GAAWD,OAAX,EAAlC,EAAwD;AACtD,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD;;AAED,SAASD,WAAT,CAAqBG,OAArB;AACE,MAAMC,SAAS,GAAGD,OAAO,CAACE,KAAR,CAAc,GAAd,CAAlB;AACA,MAAMC,IAAI,GAAG,IAAIJ,IAAJ,EAAb;AAEAI,EAAAA,IAAI,CAACC,WAAL,CAAiB,CAACH,SAAS,CAAC,CAAD,CAA3B,EAAgC,CAACA,SAAS,CAAC,CAAD,CAAV,GAAgB,CAAhD,EAAmD,CAACA,SAAS,CAAC,CAAD,CAA7D;AAEA,SAAOE,IAAP;AACD;;AASD,IAAaE,oBAAoB,GAAyB;AAExDC,EAAAA,UAAU,EAAE;AACVvB,IAAAA,IAAI,EAAE,YADI;AAEVwB,IAAAA,QAAQ,EAAEd;AAFA;AAF4C,CAAnD;;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"validators.cjs.production.min.js","sources":["../src/utils/reg_exps.ts","../src/utils/validators.ts"],"sourcesContent":["type RegExpStatment = {\n [key: string]: {\n name: string\n regex: RegExp\n description: string\n }\n}\n\nconst regExpStatments: RegExpStatment = {\n email: {\n name: 'email',\n regex: /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n description: 'this pattern is used to check if the email is valid'\n },\n\n lettersMinimum_3: {\n name: 'lettersMinimum_3',\n regex: /^[a-zA-Z]{3,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 3 letter'\n },\n\n numbersMinimum_6: {\n name: 'numbersMinimum_6',\n regex: /^[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers'\n },\n\n numbersTelephone_6: {\n name: 'numbersTelephone_6',\n regex: /^[+]*[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign'\n },\n\n numbersExact_11: {\n name: 'numbersExact_11',\n regex: /^[0-9]{11,11}$/,\n description:\n 'this pattern is used to validate that the input length exactly 12 numbers'\n },\n\n numbersMaximum_11: {\n name: 'numbersMaximum_11',\n regex: /^[0-9]{1,11}$/,\n description:\n 'this pattern is used to validate that the input length is maximum 11 numbers'\n },\n\n /***\n * this is only valid for Germany\n */\n iban: {\n name: 'iban',\n regex: /^[a-zA-Z]{2}[0-9]{20}$/,\n description:\n 'this pattern is used to validate that the input is iban (2 letters followed by exactly 20 numbers)'\n },\n\n date_de: {\n name: 'date_de',\n regex: /^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,\n description:\n 'this pattern is used to validate that the input is valid german date DD.MM.YYY'\n }\n}\n\nexport default regExpStatments\n","import regExpStatments from './reg_exps'\n\n/**\n * Validate date in german format is in the past\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateBirthDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format and the date in the past\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()) {\n return true\n }\n }\n\n return false\n}\n\nfunction parseDateDE(dateStr: string) {\n const dateArray = dateStr.split('.')\n const date = new Date()\n\n date.setFullYear(+dateArray[2], +dateArray[1] - 1, +dateArray[0])\n\n return date\n}\n\nexport const functionalValidators = {\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate\n }\n}\n"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","iban","date_de","validateBirthDate","data","dateStr","dateArray","date","test","split","Date","setFullYear","getTime","birth_date","callback"],"mappings":"oEAQA,IAAMA,EAAkC,CACtCC,MAAO,CACLC,KAAM,QACNC,MAAO,wJACPC,YAAa,uDAGfC,iBAAkB,CAChBH,KAAM,mBACNC,MAAO,iBACPC,YACE,+EAGJE,iBAAkB,CAChBJ,KAAM,mBACNC,MAAO,cACPC,YACE,gFAGJG,mBAAoB,CAClBL,KAAM,qBACNC,MAAO,kBACPC,YACE,+GAGJI,gBAAiB,CACfN,KAAM,kBACNC,MAAO,iBACPC,YACE,6EAGJK,kBAAmB,CACjBP,KAAM,oBACNC,MAAO,gBACPC,YACE,gFAMJM,KAAM,CACJR,KAAM,OACNC,MAAO,yBACPC,YACE,sGAGJO,QAAS,CACPT,KAAM,UACNC,MAAO,4CACPC,YACE,4FCzDUQ,EAAkBC,OAabC,EACbC,EACAC,WAdUhB,EAAgBW,QAAQR,MAG5Bc,KAAKJ,KASEC,EARDD,EASZE,EAAYD,EAAQI,MAAM,KAC1BF,EAAO,IAAIG,KAEjBH,EAAKI,aAAaL,EAAU,IAAKA,EAAU,GAAK,GAAIA,EAAU,IAEvDC,GAdiBK,WAAY,IAAIF,MAAOE,wCAiBb,CAClCC,WAAY,CACVpB,KAAM,aACNqB,SAAUX"} | ||
| {"version":3,"file":"validators.cjs.production.min.js","sources":["../src/utils/reg_exps.ts","../src/utils/validators.ts"],"sourcesContent":["type RegExpStatment = {\n [key: string]: {\n name: string\n regex: RegExp\n description: string\n }\n}\n\nconst regExpStatments: RegExpStatment = {\n email: {\n name: 'email',\n regex: /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n description: 'this pattern is used to check if the email is valid'\n },\n\n lettersMinimum_3: {\n name: 'lettersMinimum_3',\n regex: /^[a-zA-Z]{3,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 3 letter'\n },\n\n numbersMinimum_6: {\n name: 'numbersMinimum_6',\n regex: /^[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers'\n },\n\n numbersTelephone_6: {\n name: 'numbersTelephone_6',\n regex: /^[+]*[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign'\n },\n\n numbersExact_11: {\n name: 'numbersExact_11',\n regex: /^[0-9]{11,11}$/,\n description:\n 'this pattern is used to validate that the input length exactly 12 numbers'\n },\n\n numbersMaximum_11: {\n name: 'numbersMaximum_11',\n regex: /^[0-9]{1,11}$/,\n description:\n 'this pattern is used to validate that the input length is maximum 11 numbers'\n },\n\n /***\n * this is only valid for Germany\n */\n iban: {\n name: 'iban',\n regex: /^[a-zA-Z]{2}[0-9]{20}$/,\n description:\n 'this pattern is used to validate that the input is iban (2 letters followed by exactly 20 numbers)'\n },\n\n date_de: {\n name: 'date_de',\n regex: /^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,\n description:\n 'this pattern is used to validate that the input is valid german date DD.MM.YYY'\n }\n}\n\nexport default regExpStatments\n","import regExpStatments from './reg_exps'\n\n/**\n * Validate date in german format is in the past\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateBirthDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format and the date in the past\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()) {\n return true\n }\n }\n\n return false\n}\n\nfunction parseDateDE(dateStr: string) {\n const dateArray = dateStr.split('.')\n const date = new Date()\n\n date.setFullYear(+dateArray[2], +dateArray[1] - 1, +dateArray[0])\n\n return date\n}\n\ntype FunctionalValidators = {\n [key: string]: {\n name: string\n callback: (data: string) => boolean\n }\n}\n\nexport const functionalValidators: FunctionalValidators = {\n\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate\n }\n}\n"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","iban","date_de","validateBirthDate","data","dateStr","dateArray","date","test","split","Date","setFullYear","getTime","birth_date","callback"],"mappings":"oEAQA,IAAMA,EAAkC,CACtCC,MAAO,CACLC,KAAM,QACNC,MAAO,wJACPC,YAAa,uDAGfC,iBAAkB,CAChBH,KAAM,mBACNC,MAAO,iBACPC,YACE,+EAGJE,iBAAkB,CAChBJ,KAAM,mBACNC,MAAO,cACPC,YACE,gFAGJG,mBAAoB,CAClBL,KAAM,qBACNC,MAAO,kBACPC,YACE,+GAGJI,gBAAiB,CACfN,KAAM,kBACNC,MAAO,iBACPC,YACE,6EAGJK,kBAAmB,CACjBP,KAAM,oBACNC,MAAO,gBACPC,YACE,gFAMJM,KAAM,CACJR,KAAM,OACNC,MAAO,yBACPC,YACE,sGAGJO,QAAS,CACPT,KAAM,UACNC,MAAO,4CACPC,YACE,4FCzDUQ,EAAkBC,OAabC,EACbC,EACAC,WAdUhB,EAAgBW,QAAQR,MAG5Bc,KAAKJ,KASEC,EARDD,EASZE,EAAYD,EAAQI,MAAM,KAC1BF,EAAO,IAAIG,KAEjBH,EAAKI,aAAaL,EAAU,IAAKA,EAAU,GAAK,GAAIA,EAAU,IAEvDC,GAdiBK,WAAY,IAAIF,MAAOE,wCAwBS,CAExDC,WAAY,CACVpB,KAAM,aACNqB,SAAUX"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"validators.esm.js","sources":["../src/utils/reg_exps.ts","../src/utils/validators.ts"],"sourcesContent":["type RegExpStatment = {\n [key: string]: {\n name: string\n regex: RegExp\n description: string\n }\n}\n\nconst regExpStatments: RegExpStatment = {\n email: {\n name: 'email',\n regex: /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n description: 'this pattern is used to check if the email is valid'\n },\n\n lettersMinimum_3: {\n name: 'lettersMinimum_3',\n regex: /^[a-zA-Z]{3,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 3 letter'\n },\n\n numbersMinimum_6: {\n name: 'numbersMinimum_6',\n regex: /^[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers'\n },\n\n numbersTelephone_6: {\n name: 'numbersTelephone_6',\n regex: /^[+]*[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign'\n },\n\n numbersExact_11: {\n name: 'numbersExact_11',\n regex: /^[0-9]{11,11}$/,\n description:\n 'this pattern is used to validate that the input length exactly 12 numbers'\n },\n\n numbersMaximum_11: {\n name: 'numbersMaximum_11',\n regex: /^[0-9]{1,11}$/,\n description:\n 'this pattern is used to validate that the input length is maximum 11 numbers'\n },\n\n /***\n * this is only valid for Germany\n */\n iban: {\n name: 'iban',\n regex: /^[a-zA-Z]{2}[0-9]{20}$/,\n description:\n 'this pattern is used to validate that the input is iban (2 letters followed by exactly 20 numbers)'\n },\n\n date_de: {\n name: 'date_de',\n regex: /^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,\n description:\n 'this pattern is used to validate that the input is valid german date DD.MM.YYY'\n }\n}\n\nexport default regExpStatments\n","import regExpStatments from './reg_exps'\n\n/**\n * Validate date in german format is in the past\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateBirthDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format and the date in the past\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()) {\n return true\n }\n }\n\n return false\n}\n\nfunction parseDateDE(dateStr: string) {\n const dateArray = dateStr.split('.')\n const date = new Date()\n\n date.setFullYear(+dateArray[2], +dateArray[1] - 1, +dateArray[0])\n\n return date\n}\n\nexport const functionalValidators = {\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate\n }\n}\n"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","iban","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","dateStr","dateArray","split","date","setFullYear","functionalValidators","birth_date","callback"],"mappings":"AAQA,IAAMA,eAAe,GAAmB;AACtCC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI,EAAE,OADD;AAELC,IAAAA,KAAK,EAAE,uJAFF;AAGLC,IAAAA,WAAW,EAAE;AAHR,GAD+B;AAOtCC,EAAAA,gBAAgB,EAAE;AAChBH,IAAAA,IAAI,EAAE,kBADU;AAEhBC,IAAAA,KAAK,EAAE,gBAFS;AAGhBC,IAAAA,WAAW,EACT;AAJc,GAPoB;AActCE,EAAAA,gBAAgB,EAAE;AAChBJ,IAAAA,IAAI,EAAE,kBADU;AAEhBC,IAAAA,KAAK,EAAE,aAFS;AAGhBC,IAAAA,WAAW,EACT;AAJc,GAdoB;AAqBtCG,EAAAA,kBAAkB,EAAE;AAClBL,IAAAA,IAAI,EAAE,oBADY;AAElBC,IAAAA,KAAK,EAAE,iBAFW;AAGlBC,IAAAA,WAAW,EACT;AAJgB,GArBkB;AA4BtCI,EAAAA,eAAe,EAAE;AACfN,IAAAA,IAAI,EAAE,iBADS;AAEfC,IAAAA,KAAK,EAAE,gBAFQ;AAGfC,IAAAA,WAAW,EACT;AAJa,GA5BqB;AAmCtCK,EAAAA,iBAAiB,EAAE;AACjBP,IAAAA,IAAI,EAAE,mBADW;AAEjBC,IAAAA,KAAK,EAAE,eAFU;AAGjBC,IAAAA,WAAW,EACT;AAJe,GAnCmB;;AA0CtC;;;AAGAM,EAAAA,IAAI,EAAE;AACJR,IAAAA,IAAI,EAAE,MADF;AAEJC,IAAAA,KAAK,EAAE,wBAFH;AAGJC,IAAAA,WAAW,EACT;AAJE,GA7CgC;AAoDtCO,EAAAA,OAAO,EAAE;AACPT,IAAAA,IAAI,EAAE,SADC;AAEPC,IAAAA,KAAK,EAAE,2CAFA;AAGPC,IAAAA,WAAW,EACT;AAJK;AApD6B,CAAxC;;ACNA;;;;;;AAKA,SAAgBQ,kBAAkBC;AAChC,MAAMC,OAAO,GAAGd,eAAe,CAACW,OAAhB,CAAwBR,KAAxC;;AAGA,MAAIW,OAAO,CAACC,IAAR,CAAaF,IAAb,CAAJ,EAAwB;AACtB,QAAIG,WAAW,CAACH,IAAD,CAAX,CAAkBI,OAAlB,KAA8B,IAAIC,IAAJ,GAAWD,OAAX,EAAlC,EAAwD;AACtD,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD;;AAED,SAASD,WAAT,CAAqBG,OAArB;AACE,MAAMC,SAAS,GAAGD,OAAO,CAACE,KAAR,CAAc,GAAd,CAAlB;AACA,MAAMC,IAAI,GAAG,IAAIJ,IAAJ,EAAb;AAEAI,EAAAA,IAAI,CAACC,WAAL,CAAiB,CAACH,SAAS,CAAC,CAAD,CAA3B,EAAgC,CAACA,SAAS,CAAC,CAAD,CAAV,GAAgB,CAAhD,EAAmD,CAACA,SAAS,CAAC,CAAD,CAA7D;AAEA,SAAOE,IAAP;AACD;;AAED,IAAaE,oBAAoB,GAAG;AAClCC,EAAAA,UAAU,EAAE;AACVvB,IAAAA,IAAI,EAAE,YADI;AAEVwB,IAAAA,QAAQ,EAAEd;AAFA;AADsB,CAA7B;;;;"} | ||
| {"version":3,"file":"validators.esm.js","sources":["../src/utils/reg_exps.ts","../src/utils/validators.ts"],"sourcesContent":["type RegExpStatment = {\n [key: string]: {\n name: string\n regex: RegExp\n description: string\n }\n}\n\nconst regExpStatments: RegExpStatment = {\n email: {\n name: 'email',\n regex: /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n description: 'this pattern is used to check if the email is valid'\n },\n\n lettersMinimum_3: {\n name: 'lettersMinimum_3',\n regex: /^[a-zA-Z]{3,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 3 letter'\n },\n\n numbersMinimum_6: {\n name: 'numbersMinimum_6',\n regex: /^[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers'\n },\n\n numbersTelephone_6: {\n name: 'numbersTelephone_6',\n regex: /^[+]*[0-9]{6,}$/,\n description:\n 'this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign'\n },\n\n numbersExact_11: {\n name: 'numbersExact_11',\n regex: /^[0-9]{11,11}$/,\n description:\n 'this pattern is used to validate that the input length exactly 12 numbers'\n },\n\n numbersMaximum_11: {\n name: 'numbersMaximum_11',\n regex: /^[0-9]{1,11}$/,\n description:\n 'this pattern is used to validate that the input length is maximum 11 numbers'\n },\n\n /***\n * this is only valid for Germany\n */\n iban: {\n name: 'iban',\n regex: /^[a-zA-Z]{2}[0-9]{20}$/,\n description:\n 'this pattern is used to validate that the input is iban (2 letters followed by exactly 20 numbers)'\n },\n\n date_de: {\n name: 'date_de',\n regex: /^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,\n description:\n 'this pattern is used to validate that the input is valid german date DD.MM.YYY'\n }\n}\n\nexport default regExpStatments\n","import regExpStatments from './reg_exps'\n\n/**\n * Validate date in german format is in the past\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateBirthDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format and the date in the past\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()) {\n return true\n }\n }\n\n return false\n}\n\nfunction parseDateDE(dateStr: string) {\n const dateArray = dateStr.split('.')\n const date = new Date()\n\n date.setFullYear(+dateArray[2], +dateArray[1] - 1, +dateArray[0])\n\n return date\n}\n\ntype FunctionalValidators = {\n [key: string]: {\n name: string\n callback: (data: string) => boolean\n }\n}\n\nexport const functionalValidators: FunctionalValidators = {\n\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate\n }\n}\n"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","iban","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","dateStr","dateArray","split","date","setFullYear","functionalValidators","birth_date","callback"],"mappings":"AAQA,IAAMA,eAAe,GAAmB;AACtCC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI,EAAE,OADD;AAELC,IAAAA,KAAK,EAAE,uJAFF;AAGLC,IAAAA,WAAW,EAAE;AAHR,GAD+B;AAOtCC,EAAAA,gBAAgB,EAAE;AAChBH,IAAAA,IAAI,EAAE,kBADU;AAEhBC,IAAAA,KAAK,EAAE,gBAFS;AAGhBC,IAAAA,WAAW,EACT;AAJc,GAPoB;AActCE,EAAAA,gBAAgB,EAAE;AAChBJ,IAAAA,IAAI,EAAE,kBADU;AAEhBC,IAAAA,KAAK,EAAE,aAFS;AAGhBC,IAAAA,WAAW,EACT;AAJc,GAdoB;AAqBtCG,EAAAA,kBAAkB,EAAE;AAClBL,IAAAA,IAAI,EAAE,oBADY;AAElBC,IAAAA,KAAK,EAAE,iBAFW;AAGlBC,IAAAA,WAAW,EACT;AAJgB,GArBkB;AA4BtCI,EAAAA,eAAe,EAAE;AACfN,IAAAA,IAAI,EAAE,iBADS;AAEfC,IAAAA,KAAK,EAAE,gBAFQ;AAGfC,IAAAA,WAAW,EACT;AAJa,GA5BqB;AAmCtCK,EAAAA,iBAAiB,EAAE;AACjBP,IAAAA,IAAI,EAAE,mBADW;AAEjBC,IAAAA,KAAK,EAAE,eAFU;AAGjBC,IAAAA,WAAW,EACT;AAJe,GAnCmB;;AA0CtC;;;AAGAM,EAAAA,IAAI,EAAE;AACJR,IAAAA,IAAI,EAAE,MADF;AAEJC,IAAAA,KAAK,EAAE,wBAFH;AAGJC,IAAAA,WAAW,EACT;AAJE,GA7CgC;AAoDtCO,EAAAA,OAAO,EAAE;AACPT,IAAAA,IAAI,EAAE,SADC;AAEPC,IAAAA,KAAK,EAAE,2CAFA;AAGPC,IAAAA,WAAW,EACT;AAJK;AApD6B,CAAxC;;ACNA;;;;;;AAKA,SAAgBQ,kBAAkBC;AAChC,MAAMC,OAAO,GAAGd,eAAe,CAACW,OAAhB,CAAwBR,KAAxC;;AAGA,MAAIW,OAAO,CAACC,IAAR,CAAaF,IAAb,CAAJ,EAAwB;AACtB,QAAIG,WAAW,CAACH,IAAD,CAAX,CAAkBI,OAAlB,KAA8B,IAAIC,IAAJ,GAAWD,OAAX,EAAlC,EAAwD;AACtD,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD;;AAED,SAASD,WAAT,CAAqBG,OAArB;AACE,MAAMC,SAAS,GAAGD,OAAO,CAACE,KAAR,CAAc,GAAd,CAAlB;AACA,MAAMC,IAAI,GAAG,IAAIJ,IAAJ,EAAb;AAEAI,EAAAA,IAAI,CAACC,WAAL,CAAiB,CAACH,SAAS,CAAC,CAAD,CAA3B,EAAgC,CAACA,SAAS,CAAC,CAAD,CAAV,GAAgB,CAAhD,EAAmD,CAACA,SAAS,CAAC,CAAD,CAA7D;AAEA,SAAOE,IAAP;AACD;;AASD,IAAaE,oBAAoB,GAAyB;AAExDC,EAAAA,UAAU,EAAE;AACVvB,IAAAA,IAAI,EAAE,YADI;AAEVwB,IAAAA,QAAQ,EAAEd;AAFA;AAF4C,CAAnD;;;;"} |
+1
-1
| { | ||
| "name": "@epilot/validators", | ||
| "version": "0.0.4", | ||
| "version": "0.0.5", | ||
| "author": { | ||
@@ -5,0 +5,0 @@ "name": "epilot GmbH", |
@@ -30,3 +30,11 @@ import regExpStatments from './reg_exps' | ||
| export const functionalValidators = { | ||
| type FunctionalValidators = { | ||
| [key: string]: { | ||
| name: string | ||
| callback: (data: string) => boolean | ||
| } | ||
| } | ||
| export const functionalValidators: FunctionalValidators = { | ||
| birth_date: { | ||
@@ -33,0 +41,0 @@ name: 'birth_date', |
27076
3.49%288
2.86%