@dcl/schemas 4.13.1-20220524203836.commit-69688ca → 4.13.1-20220524210610.commit-ff19bdf

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.
Files changed (2) hide show
  1. package/README.md +11 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -38,6 +38,17 @@ export namespace MyType {
38
38
 
39
39
  In that sense, MyType can be both used as type `const a: MyType` and as object `MyType.validate(a)`.
40
40
 
41
+ Beware that `validate` has type `ValidateFunction<T>` which `ajv` creates automatically. When writing new
42
+ validations always try to implement it as an ajv validation, even if custom code is needed. See [here](https://ajv.js.org/keywords.html#define-keyword-with-code-generation-function).
43
+
44
+ In particular, don't fall in the trap of doing this:
45
+ ```ts
46
+ const validator = generateValidator<MyType>(schema)
47
+ export const validate = (mt: MyType) => validator.validate(mt) && otherValidations(mt);
48
+ ```
49
+ By doing this, all the errors reported by the `validator.validate` function are lost and never returned
50
+ to the caller.
51
+
41
52
  ## Type ownership
42
53
 
43
54
  Please add types and schemas of your domain into the `src/<team>` folder, also add your team to the [CODEOWNERS](.github/CODEOWNERS) repository to make sure nobody accidentally changes it without your team noticing it.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.13.1-20220524203836.commit-69688ca",
2
+ "version": "4.13.1-20220524210610.commit-ff19bdf",
3
3
  "name": "@dcl/schemas",
4
4
  "main": "./dist/index.js",
5
5
  "typings": "./dist/index.d.ts",
@@ -32,5 +32,5 @@
32
32
  "files": [
33
33
  "dist"
34
34
  ],
35
- "commit": "69688cadcd78fd26ca292ad37ae272619ca64074"
35
+ "commit": "ff19bdf5de2b832156a8e31622671ac9e71a71dc"
36
36
  }