smart-auth-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 +32 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -26,3 +26,35 @@ Smart, type-safe, zero-regex validation middleware for Node.js backends. Support
|
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
npm install smart-auth-validator
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Supported Fields
|
|
32
|
+
The library currently supports a wide array of built-in validation rules. You can validate these fields by simply passing their keys:
|
|
33
|
+
|
|
34
|
+
Category: Supported Fields
|
|
35
|
+
Identity "name, username, email, password"
|
|
36
|
+
Contact "phone, url"
|
|
37
|
+
Address "street, city, state, postalCode"
|
|
38
|
+
Finance "creditCard, cvv"
|
|
39
|
+
General "date, time, active (boolean)"
|
|
40
|
+
|
|
41
|
+
Simple Usage
|
|
42
|
+
To use Smart Auth Validator, simply define a schema with the fields you want to validate and pass your input data to the validate function.
|
|
43
|
+
|
|
44
|
+
Basic 3-Field Example
|
|
45
|
+
Even though the library supports 10+ fields, you can choose only the ones you need:
|
|
46
|
+
|
|
47
|
+
import { validate } from "smart-auth-validator";
|
|
48
|
+
const result = validate({ name: true, email: true, password: true }, req.body);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Error Response Format
|
|
52
|
+
If validation fails, you get a clean array explaining exactly what went wrong:
|
|
53
|
+
|
|
54
|
+
REQUIRED: Field is missing.
|
|
55
|
+
|
|
56
|
+
PATTERN: Invalid format (e.g., bad email).
|
|
57
|
+
|
|
58
|
+
MIN_LENGTH: Input is too short.
|
|
59
|
+
|
|
60
|
+
WEAK_PASSWORD: Password doesn't meet security standards.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-auth-validator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Zero-regex, type-safe authentication and form validation for Fastify and Express",
|
|
5
5
|
"author": "Muhammad Burhan Chughtai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"sideEffects": false,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"lint": "eslint src --max-warnings=0",
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"prepublishOnly": "npm run lint && npm run test && npm run build"
|
|
27
|
+
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"express": "^4.22.1",
|
|
30
30
|
"fastify": "^4 || ^5"
|