File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -67,13 +67,32 @@ Supported types:
67
67
68
68
And nested ones, too.
69
69
70
- * Specific use cases: *
70
+ #### Specific use cases
71
71
72
72
| Instance | Serialized as |
73
73
| -----------| ---------------------------------------------|
74
- | ` Date ` | ` string ` < small > via ` toISOString() ` </ small > |
74
+ | ` Date ` | ` string ` via ` toISOString() ` |
75
75
| ` RegExp ` | ` string ` |
76
76
77
+ #### Required
78
+ You can set specific fields of an object as ` required ` in your schema, by adding ` required: true ` inside the key properties.
79
+ Example:
80
+ ``` javascript
81
+ const schema = {
82
+ title: ' Example Schema with required field' ,
83
+ type: ' object' ,
84
+ properties: {
85
+ nickname: {
86
+ type: ' string'
87
+ },
88
+ mail: {
89
+ type: ' string' ,
90
+ required: true
91
+ }
92
+ }
93
+ }
94
+ ```
95
+ If the object to stringify has not the required field(s), ` fast-json-stringify ` will throw an error.
77
96
78
97
## Acknowledgements
79
98
You can’t perform that action at this time.
0 commit comments