Skip to content

Commit

Permalink
link to mterczynski.pl/joi-schema-generator in validation docs (#9700)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s authored Dec 23, 2023
1 parent d0bdb82 commit 595a9a9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/input-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ When we receive input data from an upstream API, we perform input validation to:

- We don't need to validate characteristics we don't rely on. For example, if we're just going to render a version on a badge with the same exact value from the API response and do not need to sort or transform the value, then it doesn't matter what format the version number is in. We can use a very relaxed schema to validate in this case, e.g. `Joi.string().required()`

- http://mterczynski.pl/joi-schema-generator/ is a tool that can be used to reverse engineer a schema from an API response. This can be a great starting point to tweak from. If using this as a starting point, remember to remove fields we don't rely on to render a badge.

- If theory (docs) and practice (real-world API responses) conflict, real-world outputs take precedence over documented behaviour. e.g: if the docs say version is a semver but we learn that there are real-world packages where the version number is `0.3b` or `1.2.1.27` then we should accept those values in preference to enforcing the documented API behaviour.

- Shields is descriptive rather than prescriptive. We reflect the established norms of the communities we serve.
Expand Down

0 comments on commit 595a9a9

Please sign in to comment.