Document validation semantics more

pull/4/head
Sven Slootweg 5 years ago
parent 7b44381a7d
commit 98c186ea8b

@ -189,5 +189,6 @@ How validators work:
- Every validator is simply a function that takes a single argument: the value to be validated. That means that your custom validators can just be expressed inline as single-argument functions, that either throw a `ValidationError` (exported by the module) or return an array of them (in case of multiple failures) if something is amiss.
- All thrown/returned ValidationErrors are compiled together into a single ValidationError, which has a) a .errors property with all the errors, and b) a multi-line `.message` with a human-readable description of all the errors that occurred, and at what paths.
- The default complex-datastructure validators (eg. object validation, `arrayOf`) will only check each value up until the first validator that fails, in the order they are defined. So, for example, each property of an object will be validated even if some of them fail; but once a given property has failed a validator, all the *other* validators for *that specific property* will not be run.
For more details (especially how to write validators that handle complex datastructures like objects), you'll be stuck looking at the source code for now :)
Loading…
Cancel
Save