@ibiliaze/stringman 3.5.0 → 3.6.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
@@ -78,7 +78,7 @@ export declare const getCloudinaryPublicId: (url: string) => string;
78
78
  * query({ limit: 10, skip: 20, sortBy: 'createdAt:desc', empty: '' });
79
79
  * // → "?limit=10&skip=20&sortBy=createdAt%3Adesc"
80
80
  */
81
- export declare const query: (q: Record<string, any>) => string;
81
+ export declare const query: (q: Record<string, any>, filter?: (string | null | undefined)[]) => string;
82
82
  /**
83
83
  * Build a comma-separated string from a list of object keys.
84
84
  *
package/dist/index.js CHANGED
@@ -97,10 +97,8 @@ exports.getCloudinaryPublicId = getCloudinaryPublicId;
97
97
  * query({ limit: 10, skip: 20, sortBy: 'createdAt:desc', empty: '' });
98
98
  * // → "?limit=10&skip=20&sortBy=createdAt%3Adesc"
99
99
  */
100
- const query = (q) => {
100
+ const query = (q, filter = ['', null, undefined, 'null', 'undefined']) => {
101
101
  try {
102
- // Values considered "invalid" and should be filtered out
103
- const filter = ['', null, undefined, 'null', 'undefined'];
104
102
  // Convert object to entries, filter out invalid keys/values
105
103
  const filtered = Object.entries(q).filter(([key, value]) => !filter.includes(key) && !filter.includes(value));
106
104
  // Build query string using URLSearchParams
@@ -233,15 +231,15 @@ exports.getTicketId = getTicketId;
233
231
  const invalidPw = (password, passwordLength = 8) => {
234
232
  try {
235
233
  if (password.length < passwordLength)
236
- `Password must be at least ${passwordLength} characters`;
234
+ return `Password must be at least ${passwordLength} characters`;
237
235
  if (!/[A-Z]/.test(password))
238
- 'Password must contain an uppercase letter';
236
+ return 'Password must contain an uppercase letter';
239
237
  if (!/[a-z]/.test(password))
240
- 'Password must contain a lowercase letter';
238
+ return 'Password must contain a lowercase letter';
241
239
  if (!/[0-9]/.test(password))
242
- 'Password must contain a number';
240
+ return 'Password must contain a number';
243
241
  if (!/[!@#$%^&*(),.?":{}|<>]/.test(password))
244
- 'Password must contain a special character';
242
+ return 'Password must contain a special character';
245
243
  }
246
244
  catch {
247
245
  return 'Failed to validate password';
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ibiliaze/stringman",
3
- "version": "3.5.0",
3
+ "version": "3.6.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.5.0 -m 'v3.5.0'; git push origin v3.5.0; git push",
10
+ "git": "git add .; git commit -m 'changes'; git tag -a v3.6.0 -m 'v3.6.0'; git push origin v3.6.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
@@ -95,11 +95,8 @@ export const getCloudinaryPublicId = (url: string): string => {
95
95
  * query({ limit: 10, skip: 20, sortBy: 'createdAt:desc', empty: '' });
96
96
  * // → "?limit=10&skip=20&sortBy=createdAt%3Adesc"
97
97
  */
98
- export const query = (q: Record<string, any>): string => {
98
+ export const query = (q: Record<string, any>, filter = ['', null, undefined, 'null', 'undefined']): string => {
99
99
  try {
100
- // Values considered "invalid" and should be filtered out
101
- const filter = ['', null, undefined, 'null', 'undefined'];
102
-
103
100
  // Convert object to entries, filter out invalid keys/values
104
101
  const filtered = Object.entries(q).filter(([key, value]) => !filter.includes(key) && !filter.includes(value));
105
102
 
@@ -240,11 +237,11 @@ export const getTicketId = ({
240
237
 
241
238
  export const invalidPw = (password: string, passwordLength: number = 8): string | void => {
242
239
  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';
240
+ if (password.length < passwordLength) return `Password must be at least ${passwordLength} characters`;
241
+ if (!/[A-Z]/.test(password)) return 'Password must contain an uppercase letter';
242
+ if (!/[a-z]/.test(password)) return 'Password must contain a lowercase letter';
243
+ if (!/[0-9]/.test(password)) return 'Password must contain a number';
244
+ if (!/[!@#$%^&*(),.?":{}|<>]/.test(password)) return 'Password must contain a special character';
248
245
  } catch {
249
246
  return 'Failed to validate password';
250
247
  }