Skip to content

Commit b41ea0b

Browse files
authored
Added example for referring field names in error templates
1 parent feea56b commit b41ea0b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,29 @@ const schema = {
294294
}
295295
```
296296

297+
#### Referring to Field Names
298+
299+
Field names can be referred to by using the relative `0#` JSON-pointer.
300+
301+
Example which prints additional properties that cause validation error:
302+
303+
```javascript
304+
const schema = {
305+
type: "object",
306+
properties: {
307+
size: {
308+
type: "number",
309+
},
310+
},
311+
additionalProperties: {
312+
not: true,
313+
errorMessage: “extra property is ${0#}”
314+
}
315+
}
316+
```
317+
318+
319+
297320
## Options
298321

299322
Defaults:

0 commit comments

Comments
 (0)