@ibiliaze/stringman 3.4.0 → 3.5.0

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/dist/index.d.ts CHANGED
@@ -143,3 +143,4 @@ export declare const getTicketId: ({ fixtureId, sectionName, seatName, }: {
143
143
  sectionName: string;
144
144
  seatName: string;
145
145
  }) => string;
146
+ export declare const invalidPw: (password: string, passwordLength?: number) => string | void;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTicketId = exports.getPublicIP = exports.isVideoUrl = exports.getRandomString = exports.extractImageSrcs = exports.select = exports.query = exports.getCloudinaryPublicId = exports.dp = exports.megaTrim = exports.superTrim = void 0;
3
+ exports.invalidPw = exports.getTicketId = exports.getPublicIP = exports.isVideoUrl = exports.getRandomString = exports.extractImageSrcs = exports.select = exports.query = exports.getCloudinaryPublicId = exports.dp = exports.megaTrim = exports.superTrim = void 0;
4
4
  /**
5
5
  * Clean up extra whitespace in a string.
6
6
  *
@@ -230,3 +230,21 @@ const getPublicIP = async () => {
230
230
  exports.getPublicIP = getPublicIP;
231
231
  const getTicketId = ({ fixtureId, sectionName, seatName, }) => `${sectionName}-${seatName}-${fixtureId}`;
232
232
  exports.getTicketId = getTicketId;
233
+ const invalidPw = (password, passwordLength = 8) => {
234
+ try {
235
+ if (password.length < passwordLength)
236
+ `Password must be at least ${passwordLength} characters`;
237
+ if (!/[A-Z]/.test(password))
238
+ 'Password must contain an uppercase letter';
239
+ if (!/[a-z]/.test(password))
240
+ 'Password must contain a lowercase letter';
241
+ if (!/[0-9]/.test(password))
242
+ 'Password must contain a number';
243
+ if (!/[!@#$%^&*(),.?":{}|<>]/.test(password))
244
+ 'Password must contain a special character';
245
+ }
246
+ catch {
247
+ return 'Failed to validate password';
248
+ }
249
+ };
250
+ exports.invalidPw = invalidPw;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ibiliaze/stringman",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "pub": "npm publish --access public",
10
- "git": "git add .; git commit -m 'changes'; git tag -a v3.4.0 -m 'v3.4.0'; git push origin v3.4.0; git push",
10
+ "git": "git add .; git commit -m 'changes'; git tag -a v3.5.0 -m 'v3.5.0'; git push origin v3.5.0; git push",
11
11
  "push": "npm run build; npm run git; npm run pub"
12
12
  },
13
13
  "author": "Ibi Hasanli",
package/src/index.ts CHANGED
@@ -237,3 +237,15 @@ export const getTicketId = ({
237
237
  sectionName: string;
238
238
  seatName: string;
239
239
  }) => `${sectionName}-${seatName}-${fixtureId}`;
240
+
241
+ export const invalidPw = (password: string, passwordLength: number = 8): string | void => {
242
+ try {
243
+ if (password.length < passwordLength) `Password must be at least ${passwordLength} characters`;
244
+ if (!/[A-Z]/.test(password)) 'Password must contain an uppercase letter';
245
+ if (!/[a-z]/.test(password)) 'Password must contain a lowercase letter';
246
+ if (!/[0-9]/.test(password)) 'Password must contain a number';
247
+ if (!/[!@#$%^&*(),.?":{}|<>]/.test(password)) 'Password must contain a special character';
248
+ } catch {
249
+ return 'Failed to validate password';
250
+ }
251
+ };