From d457ecde1f7bb1b69964f6eb6c5073890c3a89b9 Mon Sep 17 00:00:00 2001 From: ayoub Date: Mon, 7 Apr 2025 17:13:04 +0200 Subject: [PATCH] Auto commit for build : 78 commit by: Administrator with message : redeploy cvs --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++ index.d.ts | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 35 +++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+) create mode 100644 README.md create mode 100644 index.d.ts create mode 100644 index.js create mode 100644 package.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..15907f6 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +## what is `@d3v4pp/rex` + +`d3v4pp/rex` is an [npm package](https://www.npmjs.com/package/@d3v4pp/rex) that contains a set of regular expressions, and that's it. + +## installation & Usage + +#### Current version + +``` +npm i @d3v4pp/rex --save +``` + +#### Next version + +``` +npm i git+https://cvs.d3v4pp.fr/D3V4PP/rex.git --save +``` + +#### How to use + +```javascript +const { email, alpha, num } = require("@d3v4pp/rex"); + +email.test("email@example.com") //will return true +alpha.test("2233er") //will return false +num.test("1234") //will return true + +``` + +## Included Regular expressions + +| Regex | Description | +| :---------: | :------------------------------------------------------------------: | +| num | numeric only | +| alpha | only chars no numbers no special chars | +| alphanum | chars alphabet and numbers | +| email | a valid email | +| url | a valid url | +| ipAddress | ip addr v4 | +| password | complex password with special char, numeric uppercase and lowwercase | +| phone | french phone number | +| codePost | french zip code | +| time | time hh:mm:ss | +| price | float with a precision of two | +| date | french date dd/mm/YYYY | +| tva | french TVA, Set of values 5.5, 10 and 20 | +| prix | float with a precision of two | +| date | Fr date jj/mm/yyyy | +| password | complex password | +| motDePasse | complex password | +| matricule | european immatriculation | +| tvaIntercom | French TVA intra communautaire | +| iban | french IBAN | diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..a15e8c3 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,58 @@ +declare const alphabetique: RegExp; +declare const email: RegExp; +declare const alpha: RegExp; +declare const num: RegExp; +declare const alphanum: RegExp; +declare const url: RegExp; +declare const ipAddress: RegExp; +declare const phone: RegExp; +declare const codePost: RegExp; +declare const time: RegExp; +declare const date: RegExp; +declare const tva: RegExp; +declare const price: RegExp; + + +declare const numMask: RegExp; +declare const alphaMask: RegExp; +declare const alphanumMask: RegExp; +declare const emailMask: RegExp; +declare const urlMask: RegExp; +declare const ipAddressMask: RegExp; +declare const prix: RegExp; +declare const password: RegExp; +declare const motDePasse: RegExp; +declare const matricule: RegExp; +declare const tvaIntercom: RegExp; +declare const iban: RegExp; +declare const city: RegExp; +declare const missiontitle: RegExp; +export { + // regexs + email, + alpha, + num, + alphanum, + url, + ipAddress, + date, + time, + tva, + price, + prix, + alphabetique, + password, + motDePasse, + matricule, + tvaIntercom, + iban, + //masks + numMask, + alphaMask, + alphanumMask, + emailMask, + urlMask, + ipAddressMask, + city, + missiontitle +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..be44955 --- /dev/null +++ b/index.js @@ -0,0 +1,58 @@ +module.exports = { + + + "num": /^[0-9]+$/, + "numeric": /^[0-9]+$/, + "alpha": /^[a-zA-Z_]+$/, + "alphabetic": /^[a-zA-Z_]+$/, + "alphabetique":/^[A-Za-z\s\u00C0-\u00FF]+$/, + "alphanum": /^[a-zA-Z0-9_]+$/, + "alphanumeric": /^[a-zA-Z0-9_]+$/, + "email": /^(")?(?:[^\."\s])(?:(?:[\.])?(?:[\w\-!#$%&'*+/=?^_`{|}~]))*\1@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/, + "url": /(((^https?)|(^ftp)):\/\/((([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*)|(localhost|LOCALHOST))\/?)/i, + "ipAddress": /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, + "phone": /^(?:(?:\+|00)33|0)\s*[1-9](?:\d{2}){4}$/, + "codePost": /^(((?!(96|97|98|99|00)))[0-9]{5})$|(2A|2B|2a|2b)[0-9]{3}$|(971|972|973|974|975|976)[0-9]{2}$/, + "codePostal": /^(((?!(96|97|98|99|00)))[0-9]{5})$|(2A|2B|2a|2b)[0-9]{3}$|(971|972|973|974|975|976)[0-9]{2}$/, + "time": /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/, + "price": /^\d+(\.\d{1,2})?$/, + "prix": /^\d+(\.\d{1,2})?$/, + "date": /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/, + "tva": /^(5\.5|10|20)$/, + // "password": /(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, + + "password": /^(?=.*[A-Z])(?=.*[-!#$@%&'’*+/=?^_`{|}~])(?=.*[0-9])(?=.*[a-z]).{8,}$/, + + + + "motDePasse": /(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, + "matricule": /[A-HJ-NP-TV-Z]{2}[\s-]{0,1}[0-9]{3}[\s-]{0,1}[A-HJ-NP-TV-Z]{2}|[0-9]{2,4}[\s-]{0,1}[A-Z]{1,3}[\s-]{0,1}[0-9]{2}/, + // "matricule": /(^\d{1,4}[A-Za-z]{1,4}\d{1,2}$)|(^[A-Za-z]{1,2}\s*\d{1,3}\s*[A-Za-z]{1,2})|(^\d{1,4}-[A-Za-z]{1,4}-\d{1,2}$)|(^[A-Za-z]{1,2}-\s*\d{1,3}-\s*[A-Za-z]{1,2})$/, + "tvaIntercom": /^(FR)([0-9]{11}$)/, + "iban": /^FR\d{12}[A-Z0-9]{11}\d{2}$/, + "secuNum": /^[0-9]{15}$/, + + + + ///special My intranet + 'city' : /^[a-zA-Z \-'’áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœÁÀÂÄÃÅÇÉÈÊËÍÌÎÏÑÓÒÔÖÕÚÙÛÜÝŸÆŒ]*$/, + "missiontitle": /^[a-zA-Z \-'’áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœÁÀÂÄÃÅÇÉÈÊËÍÌÎÏÑÓÒÔÖÕÚÙÛÜÝŸÆŒ]*$/, + + + + + + + "timeMask": /[\d\s:amp]/i, + 'numMask': /[0-9]/i, + 'alphaMask': /[a-z_]/i, + 'alphanumMask': /[a-z0-9_]/i, + 'emailMask': /[\w.\-@'"!#$%&'*+/=?^_`{|}~]/i, + 'urlMask': /[a-z0-9_]/i, + 'ipAddressMask': /[\d\.]/i, + "phoneMask": /[0-9\+]/i, + "codePostMask": /[0-9ABab]/i, + 'passwordMask': /[\w.\-@'"!#$%&'*+/=?^_`{|}~]/i, + + +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..f0c8195 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "@d3v4pp/rex", + "version": "0.0.4", + "description": "a set of usefull regEx By D3v4pp", + "main": "index.js", + "scripts": { + "test":"mocha tests" + }, + "files": [ + "index.d.ts", + "index.js", + "package.json", + "README.md" + ], + "repository": { + "type": "git", + "url": "https://cvs.d3v4pp.fr/D3V4PP/Rex.git" + }, + "author": { + "name" : "Ayoub Hassani ", + "email" : "ayoub@d3v4pp.fr", + "url" : "https://d3v4pp.fr/" + }, + "funding": "https://paypal.me/SupportTheDoc", + "homepage": "https://cvs.d3v4pp.fr/D3V4PP/Rex/src/master/README.md", + "bugs": { + "url" : "https://cvs.d3v4pp.fr/D3V4PP/Rex/issues", + "email" : "ayoub@d3v4pp.fr" + }, + "keywords": ["regex","validation"], + "license": "ISC", + "devDependencies": { + "mocha": "^9.0.1" + } +}