You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+72-6Lines changed: 72 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -180,9 +180,78 @@ example, using this schema:
180
180
- The payload `{ moon: 10}` will be modified to `{ sun: 9000, moon: 10 }`.
181
181
- The payload `{ saturn: 10}` will throw an error because no condition is met.
182
182
183
+
### $id, $ref, $defs
184
+
185
+
The keywords [$id](https://json-schema.org/understanding-json-schema/structuring#id), [$ref](https://json-schema.org/understanding-json-schema/structuring#dollarref) and [$defs](https://json-schema.org/understanding-json-schema/structuring#defs) can be used to build and maintain complex schemas where the reusable parts are defined in separate schemas.
186
+
187
+
The following is the main schema and a `customer` sub-schema that defines the `contacts` and `address` properties.
If the new instance options has the `errorMessages` flag set to true, you can use the property `errorMessage` in the schema to define custom error messages.
254
+
If the new instance options has the `errorMessages` flag set to true, you can use the property `errorMessage` in the schema to define custom error messages.
186
255
187
256
```js
188
257
constschema= {
@@ -204,7 +273,7 @@ const payload = {
204
273
205
274
cabidela.validate(payload);
206
275
// throws "Error: prompt required"
207
-
````
276
+
```
208
277
209
278
## Tests
210
279
@@ -262,7 +331,7 @@ Here are some results:
262
331
59.75x faster than Ajv
263
332
264
333
Cabidela - benchmarks/80-big-ops.bench.js > allOf, two properties
265
-
1701.95x faster than Ajv
334
+
1701.95x faster than Ajv
266
335
267
336
Cabidela - benchmarks/80-big-ops.bench.js > allOf, two objects
268
337
1307.04x faster than Ajv
@@ -285,10 +354,7 @@ npm run benchmark
285
354
Cabidela supports most of JSON Schema specification, and should be useful for many applications, but it's not complete. **Currently** we do not support:
0 commit comments