File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,35 @@ const stringify = fastJson({
301301})
302302```
303303
304+ When specifying object JSON schemas for * anyOf* , add * required* validation keyword to match only the objects with the properties you want.
305+
306+ Example:
307+ ``` javascript
308+ const stringify = fastJson ({
309+ title: ' Example Schema' ,
310+ type: ' array' ,
311+ items: {
312+ anyOf: [
313+ {
314+ type: ' object' ,
315+ properties: {
316+ savedId: { type: ' string' }
317+ },
318+ // without "required" validation any object will match
319+ required: [' saveId' ]
320+ },
321+ {
322+ type: ' object' ,
323+ properties: {
324+ error: { type: ' string' }
325+ },
326+ required: [' error' ]
327+ }
328+ ]
329+ }
330+ })
331+ ```
332+
304333<a name =" if-then-else " ></a >
305334#### If/then/else
306335` fast-json-stringify ` supports ` if/then/else ` jsonschema feature. See [ ajv documentation] ( https://ajv.js.org/keywords.html#ifthenelse ) .
You can’t perform that action at this time.
0 commit comments