From 98c186ea8b559f41c3ff4e72c713e2f31273a727 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Mon, 20 May 2019 16:13:19 +0200 Subject: [PATCH] Document validation semantics more --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index afbb7b6..1fc26a6 100644 --- a/README.md +++ b/README.md @@ -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 :) \ No newline at end of file