@cleverbrush/schema 0.0.16 → 0.0.17
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 +25 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -274,6 +274,31 @@ There is a possibility to register a schema, give it a name and then reuse it:
|
|
|
274
274
|
|
|
275
275
|
// { valid: true }
|
|
276
276
|
|
|
277
|
+
Also there is a possibility to organize schemas in modules (or even submodules):
|
|
278
|
+
|
|
279
|
+
const validator = new SchemaValidator().addSchemaType("Module1.DTOs.Address", {
|
|
280
|
+
properties: {
|
|
281
|
+
id: {
|
|
282
|
+
type: "number",
|
|
283
|
+
min: 1,
|
|
284
|
+
},
|
|
285
|
+
street: "string",
|
|
286
|
+
zip: "number",
|
|
287
|
+
}
|
|
288
|
+
}).addSchemaType("Module1.Models.Person", {
|
|
289
|
+
properties: {
|
|
290
|
+
firstName: "string",
|
|
291
|
+
lastName: "string"
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
const resultPerson = await validator.schemas.Module1.Models.Person.validate({
|
|
296
|
+
fistName: 'John',
|
|
297
|
+
lastName: 'Smith'
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
const resultAddress = await validator.schemas.Module1.DTOs.Address.validate({ });
|
|
301
|
+
|
|
277
302
|
## Examples
|
|
278
303
|
|
|
279
304
|
For Examples see unit tests in the schemaValidator.tests.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleverbrush/schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"object schema validator",
|
|
6
6
|
"schema",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"build": "tsc"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@cleverbrush/deep": "0.0.
|
|
22
|
+
"@cleverbrush/deep": "0.0.17"
|
|
23
23
|
},
|
|
24
24
|
"types": "./dist/index.d.ts"
|
|
25
25
|
}
|