diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-08-06 03:52:32 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-14 19:06:19 -0400 |
commit | 807868f4404d850c29ad8ba4cd69beb9f08cecc6 (patch) | |
tree | d27da5208e684fc42b980e18b27334a62bb47657 /docs | |
parent | 674ceea74e74c5b0f432534dba981b5066ea7630 (diff) | |
download | SMAPI-807868f4404d850c29ad8ba4cd69beb9f08cecc6.tar.gz SMAPI-807868f4404d850c29ad8ba4cd69beb9f08cecc6.tar.bz2 SMAPI-807868f4404d850c29ad8ba4cd69beb9f08cecc6.zip |
add support for transparent schema errors with multiple child errors (#654)
Diffstat (limited to 'docs')
-rw-r--r-- | docs/technical/web.md | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/docs/technical/web.md b/docs/technical/web.md index 91af2f98..c13e24e9 100644 --- a/docs/technical/web.md +++ b/docs/technical/web.md @@ -61,10 +61,29 @@ against the error message (more fragile): ``` Error messages may contain special tokens: -* `@value` is replaced with the error's value field (which is usually the original field value, but - not always). -* If the validation error has exactly one sub-error and the message is set to `$transparent`, the - sub-error will be displayed instead. (The sub-error itself may be set to `$transparent`, etc.) + +* The `@value` token is replaced with the error's value field. This is usually (but not always) the + original field value. +* When an error has child errors, by default they're flattened into one message: + ``` + line | field | error + ---- | ---------- | ------------------------------------------------------------------------- + 4 | Changes[0] | JSON does not match schema from 'then'. + | | ==> Changes[0].ToArea.Y: Invalid type. Expected Integer but got String. + | | ==> Changes[0].ToArea: Missing required fields: Height. + ``` + + If you set the message for an error to `$transparent`, the parent error is omitted entirely and + the child errors are shown instead: + ``` + line | field | error + ---- | ------------------- | ---------------------------------------------- + 8 | Changes[0].ToArea.Y | Invalid type. Expected Integer but got String. + 8 | Changes[0].ToArea | Missing required fields: Height. + ``` + + The child errors themselves may be marked `$transparent`, etc. If an error has no child errors, + this override is ignored. Caveats: * To override an error from a `then` block, the `@errorMessages` must be inside the `then` block |