qa-smart-validator 1.0.0 → 1.0.1
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 +3 -3
- package/package.json +4 -4
- package/src/validators/emailValidator.js +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A small, framework-agnostic validation library for QA automation. Use it in Node
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Email validator** – Standard format; supports gmail.com, outlook.com, yahoo.com, and custom domains (e.g.
|
|
7
|
+
- **Email validator** – Standard format; supports gmail.com, outlook.com, yahoo.com, and custom domains (e.g. example.com). Rejects empty, null, and invalid formats.
|
|
8
8
|
- **String validator** – Ensures value is a string and enforces optional min/max length (after trim). Clear, controlled errors.
|
|
9
9
|
- **Phone validator** – Digits only; length 10–15. Rejects empty, null, non-digits, and out-of-range length.
|
|
10
10
|
- **safeValidate(fn)** – Wraps any sync validation in try/catch. Returns `{ valid: true, data }` or `{ valid: false, error }` so execution never throws.
|
|
@@ -37,11 +37,11 @@ import {
|
|
|
37
37
|
|
|
38
38
|
### validateEmail(email)
|
|
39
39
|
|
|
40
|
-
Supports gmail.com, outlook.com, yahoo.com, and custom domains (e.g.
|
|
40
|
+
Supports gmail.com, outlook.com, yahoo.com, and custom domains (e.g. example.com). Rejects empty, null, and invalid formats.
|
|
41
41
|
|
|
42
42
|
```javascript
|
|
43
43
|
validateEmail('user@gmail.com'); // { valid: true, message: 'Valid email' }
|
|
44
|
-
validateEmail('admin@
|
|
44
|
+
validateEmail('admin@example.com'); // { valid: true, message: 'Valid email' }
|
|
45
45
|
validateEmail(''); // throws ValidationError: Email cannot be empty
|
|
46
46
|
validateEmail(null); // throws ValidationError: Email is required
|
|
47
47
|
validateEmail('not-an-email'); // throws ValidationError: Invalid email format
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qa-smart-validator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Reusable validation library for QA automation testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"author": "Sarath Sasidharan <sarathsasidharan13031997@gmail.com>",
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "https://github.com/
|
|
31
|
+
"url": "https://github.com/sharath-sasidharan/-qa-smart-validator.git"
|
|
32
32
|
},
|
|
33
33
|
"bugs": {
|
|
34
|
-
"url": "https://github.com/
|
|
34
|
+
"url": "https://github.com/sharath-sasidharan/-qa-smart-validator/issues"
|
|
35
35
|
},
|
|
36
|
-
"homepage": "https://github.com/
|
|
36
|
+
"homepage": "https://github.com/sharath-sasidharan/-qa-smart-validator#readme",
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=18"
|
|
39
39
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Email validator for QA automation.
|
|
3
3
|
* Validates standard email format. Supports gmail.com, outlook.com, yahoo.com,
|
|
4
|
-
* and custom domains (e.g.
|
|
4
|
+
* and custom domains (e.g. example.com). Rejects empty, null, and invalid formats.
|
|
5
5
|
* @module validators/emailValidator
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -18,7 +18,7 @@ const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
|
18
18
|
* @throws {ValidationError} If email is empty, null, not a string, or invalid format.
|
|
19
19
|
* @example
|
|
20
20
|
* validateEmail('user@gmail.com'); // { valid: true, message: 'Valid email' }
|
|
21
|
-
* validateEmail('admin@
|
|
21
|
+
* validateEmail('admin@example.com'); // { valid: true, message: 'Valid email' }
|
|
22
22
|
* validateEmail(''); // throws ValidationError: Email cannot be empty
|
|
23
23
|
* validateEmail(null); // throws ValidationError: Email is required
|
|
24
24
|
*/
|