validno 0.3.4 → 0.3.6
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 +6 -1
- package/dist/dev.js +54 -9
- package/dist/engine/ValidnoResult.js +2 -4
- package/dist/engine/methods/handleNestedKey.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
A lightweight and flexible TypeScript validation library for Node.js applications.
|
|
4
4
|
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
Check out docs at [https://validno.kodzero.pro](https://validno.kodzero.pro)
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
```bash
|
|
@@ -514,4 +518,5 @@ const newUser = {
|
|
|
514
518
|
const result = userSchema.validate<User>(newUser, ['name', 'email'])
|
|
515
519
|
|
|
516
520
|
// ...or use automatic type inference based on the object
|
|
517
|
-
const result = userSchema.validate(newUser, ['name', 'email'])
|
|
521
|
+
const result = userSchema.validate(newUser, ['name', 'email'])
|
|
522
|
+
```
|
package/dist/dev.js
CHANGED
|
@@ -1,12 +1,57 @@
|
|
|
1
1
|
import Schema from './index.js';
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const configSchema = new Schema({
|
|
3
|
+
api: {
|
|
4
|
+
port: {
|
|
5
|
+
type: Number,
|
|
6
|
+
required: true,
|
|
7
|
+
rules: { min: 1000, max: 9999 }
|
|
8
|
+
},
|
|
9
|
+
cors: {
|
|
10
|
+
enabled: { type: Boolean, required: true },
|
|
11
|
+
origins: {
|
|
12
|
+
type: Array,
|
|
13
|
+
eachType: String,
|
|
14
|
+
required: false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
rateLimit: {
|
|
18
|
+
enabled: { type: Boolean, required: true },
|
|
19
|
+
maxRequests: {
|
|
20
|
+
type: Number,
|
|
21
|
+
required: false,
|
|
22
|
+
rules: { min: 1, max: 10000 }
|
|
23
|
+
},
|
|
24
|
+
windowMs: {
|
|
25
|
+
type: Number,
|
|
26
|
+
required: false,
|
|
27
|
+
rules: { min: 1000, max: 86400000 }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
7
30
|
}
|
|
8
31
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
32
|
+
const exampleConfigFile = {
|
|
33
|
+
"app": {
|
|
34
|
+
"name": "MyApp",
|
|
35
|
+
"version": "1.0.0",
|
|
36
|
+
"environment": "development"
|
|
37
|
+
},
|
|
38
|
+
"database": {
|
|
39
|
+
"host": "localhost",
|
|
40
|
+
"port": 5432,
|
|
41
|
+
"name": "myappdb",
|
|
42
|
+
"ssl": false
|
|
43
|
+
},
|
|
44
|
+
"api": {
|
|
45
|
+
"port": 3000,
|
|
46
|
+
"cors": {
|
|
47
|
+
"enabled": true,
|
|
48
|
+
"origins": ["http://localhost:3000"]
|
|
49
|
+
},
|
|
50
|
+
"rateLimit": {
|
|
51
|
+
"enabled": true,
|
|
52
|
+
"maxRequests": 1000,
|
|
53
|
+
"windowMs": 60000
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
const res = configSchema.validate(exampleConfigFile);
|
|
@@ -19,12 +19,10 @@ class ValidnoResult {
|
|
|
19
19
|
fixParentByChilds(parentKey, childChecks = []) {
|
|
20
20
|
const isEveryOk = childChecks.every(check => check === true);
|
|
21
21
|
this.setKeyStatus(parentKey, isEveryOk);
|
|
22
|
-
if (isEveryOk)
|
|
22
|
+
if (isEveryOk)
|
|
23
23
|
this.setPassed(parentKey);
|
|
24
|
-
|
|
25
|
-
else {
|
|
24
|
+
else
|
|
26
25
|
this.setFailed(parentKey);
|
|
27
|
-
}
|
|
28
26
|
}
|
|
29
27
|
setMissing(key, errMsg) {
|
|
30
28
|
const error = errMsg || _errors.getMissingError(key);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "validno",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "A lightweight TypeScript validation library for runtime data validation.",
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"description": "A lightweight TypeScript validation library for runtime data validation. Used as part of Kodzero API framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"tsc": "tsc -b src/",
|