Skip to content

Commit a6f7292

Browse files
committed
Updated README.md
1 parent 78158d8 commit a6f7292

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,32 @@ Supported types:
6767

6868
And nested ones, too.
6969

70-
*Specific use cases:*
70+
#### Specific use cases
7171

7272
| Instance | Serialized as |
7373
| -----------|---------------------------------------------|
74-
| `Date` | `string` <small>via `toISOString()`</small> |
74+
| `Date` | `string` via `toISOString()` |
7575
| `RegExp` | `string` |
7676

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.
7796

7897
## Acknowledgements
7998

0 commit comments

Comments
 (0)