@epilot/validators
Advanced tools
+7
-0
@@ -5,2 +5,9 @@ # Changelog | ||
| ### [0.0.9](https://gitlab.com/e-pilot/product/frontend/base/validators/compare/v0.0.8...v0.0.9) (2021-05-04) | ||
| ### Features | ||
| * **future-date:** add future date validator ([4c2db1c](https://gitlab.com/e-pilot/product/frontend/base/validators/commit/4c2db1c71c4d493282c4f23e609492606071a18f)) | ||
| ### [0.0.8](https://gitlab.com/e-pilot/product/frontend/base/validators/compare/v0.0.7...v0.0.8) (2021-05-04) | ||
@@ -7,0 +14,0 @@ |
@@ -8,2 +8,8 @@ import IBAN from 'iban'; | ||
| export declare function validateBirthDate(data: string): boolean; | ||
| /** | ||
| * Validate date is 14 days in the future | ||
| * @param data date as string DD.MM.YYY | ||
| * @returns boolean | ||
| */ | ||
| export declare function validateFutureDate(data: string): boolean; | ||
| declare type FunctionalValidators = { | ||
@@ -10,0 +16,0 @@ [key: string]: { |
@@ -64,3 +64,20 @@ 'use strict'; | ||
| } | ||
| /** | ||
| * Validate date is 14 days in the future | ||
| * @param data date as string DD.MM.YYY | ||
| * @returns boolean | ||
| */ | ||
| function validateFutureDate(data) { | ||
| var de_date = regExpStatments.date_de.regex; // check if the data format matches the de format | ||
| if (de_date.test(data)) { | ||
| if (parseDateDE(data).getTime() < new Date().getTime() + 14 * 24 * 60 * 60 * 1000) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| function parseDateDE(dateStr) { | ||
@@ -92,2 +109,7 @@ var dateArray = dateStr.split('.'); | ||
| description: 'this function will validate that the date is in the past' | ||
| }, | ||
| future_date_14: { | ||
| name: 'future_date_14', | ||
| callback: validateFutureDate, | ||
| description: 'this function will validate that the date is in the future with 14 days at least' | ||
| } | ||
@@ -101,3 +123,4 @@ }; | ||
| exports.validateBirthDate = validateBirthDate; | ||
| exports.validateFutureDate = validateFutureDate; | ||
| exports.validateIBAN = validateIBAN; | ||
| //# sourceMappingURL=validators.cjs.development.js.map |
@@ -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 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'\nimport IBAN from 'iban'\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 description: string\n }\n}\n\n/**\n * Validate iban and validate its syntax\n * @param data iban string\n * @returns boolean\n */\nexport function validateIBAN(data: string): boolean {\n return IBAN.isValid(data)\n}\n\nexport const functionalValidators: FunctionalValidators = {\n iban: {\n name: 'iban',\n callback: validateIBAN,\n description:\n 'this validation function will validate the syntax of the provided iban'\n },\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate,\n description:\n 'this function will validate that the date is in the past'\n }\n}\n\nexport const IBAN_Specifications = IBAN.countries"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","dateStr","dateArray","split","date","setFullYear","validateIBAN","IBAN","isValid","functionalValidators","iban","callback","birth_date","IBAN_Specifications","countries"],"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,E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Aab,IAAb,CAAP;AACD;AAED,IAAac,oBAAoB,GAAyB;AACxDC,EAAAA,IAAI,EAAE;AACJzB,IAAAA,IAAI,EAAE,MADF;AAEJ0B,IAAAA,QAAQ,EAAEL,YAFN;AAGJnB,IAAAA,WAAW,EACT;AAJE,GADkD;AAOxDyB,EAAAA,UAAU,EAAE;AACV3B,IAAAA,IAAI,EAAE,YADI;AAEV0B,IAAAA,QAAQ,EAAEjB,iBAFA;AAGVP,IAAAA,WAAW,EACT;AAJQ;AAP4C,CAAnD;AAeP,IAAa0B,mBAAmB,GAAGN,IAAI,CAACO,SAAjC;;;;;;;;"} | ||
| {"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 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'\nimport IBAN from 'iban'\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\n\n/**\n * Validate date is 14 days in the future\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateFutureDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()+(14*24*60*60*1000)) {\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 description: string\n }\n}\n\n/**\n * Validate iban and validate its syntax\n * @param data iban string\n * @returns boolean\n */\nexport function validateIBAN(data: string): boolean {\n return IBAN.isValid(data)\n}\n\nexport const functionalValidators: FunctionalValidators = {\n iban: {\n name: 'iban',\n callback: validateIBAN,\n description:\n 'this validation function will validate the syntax of the provided iban'\n },\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate,\n description:\n 'this function will validate that the date is in the past'\n },\n future_date_14: {\n name: 'future_date_14',\n callback: validateFutureDate,\n description:\n 'this function will validate that the date is in the future with 14 days at least'\n }\n}\n\nexport const IBAN_Specifications = IBAN.countries"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","validateFutureDate","dateStr","dateArray","split","date","setFullYear","validateIBAN","IBAN","isValid","functionalValidators","iban","callback","birth_date","future_date_14","IBAN_Specifications","countries"],"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;AA0CtCM,EAAAA,OAAO,EAAE;AACPR,IAAAA,IAAI,EAAE,SADC;AAEPC,IAAAA,KAAK,EAAE,2CAFA;AAGPC,IAAAA,WAAW,EACT;AAJK;AA1C6B,CAAxC;;AC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AAJE,GADkD;AAOxD0B,EAAAA,UAAU,EAAE;AACV5B,IAAAA,IAAI,EAAE,YADI;AAEV2B,IAAAA,QAAQ,EAAElB,iBAFA;AAGVP,IAAAA,WAAW,EACT;AAJQ,GAP4C;AAaxD2B,EAAAA,cAAc,EAAE;AACd7B,IAAAA,IAAI,EAAE,gBADQ;AAEd2B,IAAAA,QAAQ,EAAEX,kBAFI;AAGdd,IAAAA,WAAW,EACT;AAJY;AAbwC,CAAnD;AAqBP,IAAa4B,mBAAmB,GAAGP,IAAI,CAACQ,SAAjC;;;;;;;;;"} |
@@ -1,2 +0,2 @@ | ||
| "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("iban"))&&"object"==typeof e&&"default"in e?e.default:e,i={email:{name:"email",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,}))$/,description:"this pattern is used to check if the email is valid"},lettersMinimum_3:{name:"lettersMinimum_3",regex:/^[a-zA-Z]{3,}$/,description:"this pattern is used to validate that the input length is at least 3 letter"},numbersMinimum_6:{name:"numbersMinimum_6",regex:/^[0-9]{6,}$/,description:"this pattern is used to validate that the input length is at least 6 numbers"},numbersTelephone_6:{name:"numbersTelephone_6",regex:/^[+]*[0-9]{6,}$/,description:"this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign"},numbersExact_11:{name:"numbersExact_11",regex:/^[0-9]{11,11}$/,description:"this pattern is used to validate that the input length exactly 12 numbers"},numbersMaximum_11:{name:"numbersMaximum_11",regex:/^[0-9]{1,11}$/,description:"this pattern is used to validate that the input length is maximum 11 numbers"},date_de:{name:"date_de",regex:/^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,description:"this pattern is used to validate that the input is valid german date DD.MM.YYY"}};function a(e){var t,a,n;return!!(i.date_de.regex.test(e)&&(t=e,a=t.split("."),n=new Date,n.setFullYear(+a[2],+a[1]-1,+a[0]),n).getTime()<(new Date).getTime())}function n(e){return t.isValid(e)}var s={iban:{name:"iban",callback:n,description:"this validation function will validate the syntax of the provided iban"},birth_date:{name:"birth_date",callback:a,description:"this function will validate that the date is in the past"}};exports.IBAN_Specifications=t.countries,exports.functionalValidators=s,exports.regExpStatments=i,exports.validateBirthDate=a,exports.validateIBAN=n; | ||
| "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("iban"))&&"object"==typeof e&&"default"in e?e.default:e,i={email:{name:"email",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,}))$/,description:"this pattern is used to check if the email is valid"},lettersMinimum_3:{name:"lettersMinimum_3",regex:/^[a-zA-Z]{3,}$/,description:"this pattern is used to validate that the input length is at least 3 letter"},numbersMinimum_6:{name:"numbersMinimum_6",regex:/^[0-9]{6,}$/,description:"this pattern is used to validate that the input length is at least 6 numbers"},numbersTelephone_6:{name:"numbersTelephone_6",regex:/^[+]*[0-9]{6,}$/,description:"this pattern is used to validate that the input length is at least 6 numbers and it could start with + sign"},numbersExact_11:{name:"numbersExact_11",regex:/^[0-9]{11,11}$/,description:"this pattern is used to validate that the input length exactly 12 numbers"},numbersMaximum_11:{name:"numbersMaximum_11",regex:/^[0-9]{1,11}$/,description:"this pattern is used to validate that the input length is maximum 11 numbers"},date_de:{name:"date_de",regex:/^[0-3][0-9][.][0-1][0-9][.][1|2][0-9]{3}$/,description:"this pattern is used to validate that the input is valid german date DD.MM.YYY"}};function a(e){return!!(i.date_de.regex.test(e)&&s(e).getTime()<(new Date).getTime())}function n(e){return!!(i.date_de.regex.test(e)&&s(e).getTime()<(new Date).getTime()+12096e5)}function s(e){var t=e.split("."),i=new Date;return i.setFullYear(+t[2],+t[1]-1,+t[0]),i}function r(e){return t.isValid(e)}var u={iban:{name:"iban",callback:r,description:"this validation function will validate the syntax of the provided iban"},birth_date:{name:"birth_date",callback:a,description:"this function will validate that the date is in the past"},future_date_14:{name:"future_date_14",callback:n,description:"this function will validate that the date is in the future with 14 days at least"}};exports.IBAN_Specifications=t.countries,exports.functionalValidators=u,exports.regExpStatments=i,exports.validateBirthDate=a,exports.validateFutureDate=n,exports.validateIBAN=r; | ||
| //# sourceMappingURL=validators.cjs.production.min.js.map |
@@ -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 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'\nimport IBAN from 'iban'\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 description: string\n }\n}\n\n/**\n * Validate iban and validate its syntax\n * @param data iban string\n * @returns boolean\n */\nexport function validateIBAN(data: string): boolean {\n return IBAN.isValid(data)\n}\n\nexport const functionalValidators: FunctionalValidators = {\n iban: {\n name: 'iban',\n callback: validateIBAN,\n description:\n 'this validation function will validate the syntax of the provided iban'\n },\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate,\n description:\n 'this function will validate that the date is in the past'\n }\n}\n\nexport const IBAN_Specifications = IBAN.countries"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","date_de","validateBirthDate","data","dateStr","dateArray","date","test","split","Date","setFullYear","getTime","validateIBAN","IBAN","isValid","functionalValidators","iban","callback","birth_date","countries"],"mappings":"+IAQMA,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,gFAGJM,QAAS,CACPR,KAAM,UACNC,MAAO,4CACPC,YACE,4FC9CUO,EAAkBC,OAabC,EACbC,EACAC,WAdUf,EAAgBU,QAAQP,MAG5Ba,KAAKJ,KASEC,EARDD,EASZE,EAAYD,EAAQI,MAAM,KAC1BF,EAAO,IAAIG,KAEjBH,EAAKI,aAAaL,EAAU,IAAKA,EAAU,GAAK,GAAIA,EAAU,IAEvDC,GAdiBK,WAAY,IAAIF,MAAOE,oBA8BjCC,EAAaT,UACpBU,EAAKC,QAAQX,GAGtB,IAAaY,EAA6C,CACxDC,KAAM,CACJvB,KAAM,OACNwB,SAAUL,EACVjB,YACE,0EAEJuB,WAAY,CACVzB,KAAM,aACNwB,SAAUf,EACVP,YACE,yFAI6BkB,EAAKM"} | ||
| {"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 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'\nimport IBAN from 'iban'\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\n\n/**\n * Validate date is 14 days in the future\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateFutureDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()+(14*24*60*60*1000)) {\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 description: string\n }\n}\n\n/**\n * Validate iban and validate its syntax\n * @param data iban string\n * @returns boolean\n */\nexport function validateIBAN(data: string): boolean {\n return IBAN.isValid(data)\n}\n\nexport const functionalValidators: FunctionalValidators = {\n iban: {\n name: 'iban',\n callback: validateIBAN,\n description:\n 'this validation function will validate the syntax of the provided iban'\n },\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate,\n description:\n 'this function will validate that the date is in the past'\n },\n future_date_14: {\n name: 'future_date_14',\n callback: validateFutureDate,\n description:\n 'this function will validate that the date is in the future with 14 days at least'\n }\n}\n\nexport const IBAN_Specifications = IBAN.countries"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","date_de","validateBirthDate","data","test","parseDateDE","getTime","Date","validateFutureDate","dateStr","dateArray","split","date","setFullYear","validateIBAN","IBAN","isValid","functionalValidators","iban","callback","birth_date","future_date_14","countries"],"mappings":"+IAQMA,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,gFAGJM,QAAS,CACPR,KAAM,UACNC,MAAO,4CACPC,YACE,4FC9CUO,EAAkBC,YAChBZ,EAAgBU,QAAQP,MAG5BU,KAAKD,IACXE,EAAYF,GAAMG,WAAY,IAAIC,MAAOD,oBAcjCE,EAAmBL,YACjBZ,EAAgBU,QAAQP,MAG5BU,KAAKD,IACXE,EAAYF,GAAMG,WAAY,IAAIC,MAAOD,UAAW,SAQ5D,SAASD,EAAYI,OACbC,EAAYD,EAAQE,MAAM,KAC1BC,EAAO,IAAIL,YAEjBK,EAAKC,aAAaH,EAAU,IAAKA,EAAU,GAAK,GAAIA,EAAU,IAEvDE,WAgBOE,EAAaX,UACpBY,EAAKC,QAAQb,GAGtB,IAAac,EAA6C,CACxDC,KAAM,CACJzB,KAAM,OACN0B,SAAUL,EACVnB,YACE,0EAEJyB,WAAY,CACV3B,KAAM,aACN0B,SAAUjB,EACVP,YACE,4DAEJ0B,eAAgB,CACd5B,KAAM,iBACN0B,SAAUX,EACVb,YACE,iHAI6BoB,EAAKO"} |
@@ -58,3 +58,20 @@ import IBAN from 'iban'; | ||
| } | ||
| /** | ||
| * Validate date is 14 days in the future | ||
| * @param data date as string DD.MM.YYY | ||
| * @returns boolean | ||
| */ | ||
| function validateFutureDate(data) { | ||
| var de_date = regExpStatments.date_de.regex; // check if the data format matches the de format | ||
| if (de_date.test(data)) { | ||
| if (parseDateDE(data).getTime() < new Date().getTime() + 14 * 24 * 60 * 60 * 1000) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| function parseDateDE(dateStr) { | ||
@@ -86,2 +103,7 @@ var dateArray = dateStr.split('.'); | ||
| description: 'this function will validate that the date is in the past' | ||
| }, | ||
| future_date_14: { | ||
| name: 'future_date_14', | ||
| callback: validateFutureDate, | ||
| description: 'this function will validate that the date is in the future with 14 days at least' | ||
| } | ||
@@ -91,3 +113,3 @@ }; | ||
| export { IBAN_Specifications, functionalValidators, regExpStatments, validateBirthDate, validateIBAN }; | ||
| export { IBAN_Specifications, functionalValidators, regExpStatments, validateBirthDate, validateFutureDate, validateIBAN }; | ||
| //# sourceMappingURL=validators.esm.js.map |
@@ -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 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'\nimport IBAN from 'iban'\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 description: string\n }\n}\n\n/**\n * Validate iban and validate its syntax\n * @param data iban string\n * @returns boolean\n */\nexport function validateIBAN(data: string): boolean {\n return IBAN.isValid(data)\n}\n\nexport const functionalValidators: FunctionalValidators = {\n iban: {\n name: 'iban',\n callback: validateIBAN,\n description:\n 'this validation function will validate the syntax of the provided iban'\n },\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate,\n description:\n 'this function will validate that the date is in the past'\n }\n}\n\nexport const IBAN_Specifications = IBAN.countries"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","dateStr","dateArray","split","date","setFullYear","validateIBAN","IBAN","isValid","functionalValidators","iban","callback","birth_date","IBAN_Specifications","countries"],"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;AAmCtC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A,QAAQ,EAAEjB,iBAFA;AAGVP,IAAAA,WAAW,EACT;AAJQ;AAP4C,CAAnD;AAeP,IAAa0B,mBAAmB,GAAGN,IAAI,CAACO,SAAjC;;;;"} | ||
| {"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 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'\nimport IBAN from 'iban'\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\n\n/**\n * Validate date is 14 days in the future\n * @param data date as string DD.MM.YYY\n * @returns boolean\n */\nexport function validateFutureDate(data: string): boolean {\n const de_date = regExpStatments.date_de.regex\n // check if the data format matches the de format\n\n if (de_date.test(data)) {\n if (parseDateDE(data).getTime() < new Date().getTime()+(14*24*60*60*1000)) {\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 description: string\n }\n}\n\n/**\n * Validate iban and validate its syntax\n * @param data iban string\n * @returns boolean\n */\nexport function validateIBAN(data: string): boolean {\n return IBAN.isValid(data)\n}\n\nexport const functionalValidators: FunctionalValidators = {\n iban: {\n name: 'iban',\n callback: validateIBAN,\n description:\n 'this validation function will validate the syntax of the provided iban'\n },\n birth_date: {\n name: 'birth_date',\n callback: validateBirthDate,\n description:\n 'this function will validate that the date is in the past'\n },\n future_date_14: {\n name: 'future_date_14',\n callback: validateFutureDate,\n description:\n 'this function will validate that the date is in the future with 14 days at least'\n }\n}\n\nexport const IBAN_Specifications = IBAN.countries"],"names":["regExpStatments","email","name","regex","description","lettersMinimum_3","numbersMinimum_6","numbersTelephone_6","numbersExact_11","numbersMaximum_11","date_de","validateBirthDate","data","de_date","test","parseDateDE","getTime","Date","validateFutureDate","dateStr","dateArray","split","date","setFullYear","validateIBAN","IBAN","isValid","functionalValidators","iban","callback","birth_date","future_date_14","IBAN_Specifications","countries"],"mappings":";;AAQA,IAAMA,eAAe,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EACT;AAJY;AAbwC,CAAnD;AAqBP,IAAa4B,mBAAmB,GAAGP,IAAI,CAACQ,SAAjC;;;;"} |
+1
-1
| { | ||
| "name": "@epilot/validators", | ||
| "version": "0.0.8", | ||
| "version": "0.0.9", | ||
| "author": { | ||
@@ -5,0 +5,0 @@ "name": "epilot GmbH", |
@@ -22,2 +22,21 @@ import regExpStatments from './reg_exps' | ||
| /** | ||
| * Validate date is 14 days in the future | ||
| * @param data date as string DD.MM.YYY | ||
| * @returns boolean | ||
| */ | ||
| export function validateFutureDate(data: string): boolean { | ||
| const de_date = regExpStatments.date_de.regex | ||
| // check if the data format matches the de format | ||
| if (de_date.test(data)) { | ||
| if (parseDateDE(data).getTime() < new Date().getTime()+(14*24*60*60*1000)) { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
| function parseDateDE(dateStr: string) { | ||
@@ -61,2 +80,8 @@ const dateArray = dateStr.split('.') | ||
| 'this function will validate that the date is in the past' | ||
| }, | ||
| future_date_14: { | ||
| name: 'future_date_14', | ||
| callback: validateFutureDate, | ||
| description: | ||
| 'this function will validate that the date is in the future with 14 days at least' | ||
| } | ||
@@ -63,0 +88,0 @@ } |
36041
18.79%393
20.55%