@akadenia/helpers 1.7.1 → 1.7.2
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/README.MD +10 -2
- package/dist/text.js +26 -3
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -392,8 +392,9 @@ Filter an array of objects based on a specific property and its corresponding va
|
|
|
392
392
|
Returns an array containing all objects that have the specified property with the given value.
|
|
393
393
|
|
|
394
394
|
Template
|
|
395
|
+
```typescript
|
|
395
396
|
T extends Record<string, any>
|
|
396
|
-
|
|
397
|
+
```
|
|
397
398
|
Arguments
|
|
398
399
|
|Name|Type|Required|Description|
|
|
399
400
|
|--|--|--|--|
|
|
@@ -407,7 +408,9 @@ It compares the key-value pairs of the sub-object with the corresponding key-val
|
|
|
407
408
|
Returns true If all key-value pairs in the sub-object are found in the main object; otherwise, it returns false.
|
|
408
409
|
|
|
409
410
|
Template
|
|
411
|
+
```typescript
|
|
410
412
|
T extends Record<string, any>
|
|
413
|
+
```
|
|
411
414
|
|
|
412
415
|
Arguments
|
|
413
416
|
|Name|Type|Required|Description|
|
|
@@ -422,7 +425,9 @@ Returns the first object found in the array that contains the sub-object or null
|
|
|
422
425
|
if no match is found.
|
|
423
426
|
|
|
424
427
|
Template
|
|
428
|
+
```typescript
|
|
425
429
|
T extends Record<string, any>
|
|
430
|
+
```
|
|
426
431
|
|
|
427
432
|
Arguments
|
|
428
433
|
|Name|Type|Required|Description|
|
|
@@ -436,7 +441,9 @@ Filters an array of objects based on the presence of a specific sub-object withi
|
|
|
436
441
|
Returns an array containing all objects from the input array that contain the specified sub-object.
|
|
437
442
|
|
|
438
443
|
Template
|
|
444
|
+
```typescript
|
|
439
445
|
T extends Record<string, any>
|
|
446
|
+
```
|
|
440
447
|
|
|
441
448
|
Arguments
|
|
442
449
|
|Name|Type|Required|Description|
|
|
@@ -522,7 +529,8 @@ Common types according to [commitlint-config-conventional (based on the Angular
|
|
|
522
529
|
- revert
|
|
523
530
|
- style
|
|
524
531
|
- test
|
|
525
|
-
|
|
532
|
+
|
|
533
|
+
if you introduce a breaking change, please add BREAKING CHANGE in the pull request description
|
|
526
534
|
|
|
527
535
|
## License
|
|
528
536
|
|
package/dist/text.js
CHANGED
|
@@ -240,9 +240,32 @@ exports.enforceCharacterLimit = enforceCharacterLimit;
|
|
|
240
240
|
* @returns The boolean value when the condition is met
|
|
241
241
|
*/
|
|
242
242
|
const isValidEmail = (email) => {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
// First check for null/undefined
|
|
244
|
+
if (!email) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
// Check if the email has an @ symbol and the length of the email tokens is exactly 2
|
|
248
|
+
const parts = email.split("@");
|
|
249
|
+
if (parts.length !== 2) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
const [local, domain] = parts;
|
|
253
|
+
// Check local part rules
|
|
254
|
+
if (!local || local.length === 0) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
if (local.startsWith(".") || local.endsWith(".")) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
if (local.includes("..")) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._+-]*$/.test(local)) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
// Check domain part rules
|
|
267
|
+
const domainRegex = /^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/;
|
|
268
|
+
return domainRegex.test(domain);
|
|
246
269
|
};
|
|
247
270
|
exports.isValidEmail = isValidEmail;
|
|
248
271
|
/**
|