Browse Source

Explicitly document that the error object is not an actual uppercase-E Error

master
Sven Slootweg 1 year ago
parent
commit
8cdceffb15
  1. 2
      README.md

2
README.md

@ -20,6 +20,8 @@ Creating and maintaining open-source modules is a lot of work. A donation is als
The constructor for `validatem`'s `ValidationError` type. This is invoked like any other `Error` constructor, but you may optionally pass extra metadata that should be stored on the error.
__Note that, for performance reasons (preventing stacktrace collection), the returned object does not *actually* inherit from `Error`!__ This should not affect its correct functioning, considering that the stacktraces of individual validators are not used in Validatem, and `ValidationError`s should never be thrown outside of a validator context anyway.
__Unless you are implementing a parser and using virtual properties, you probably do not need to specify the `path` property.__ Combinators like `arrayOf` will insert their path segments after-the-fact by themselves, your validator does not need to do this.
* __message:__ A description of the validation problem. This should be formatted in such a way that it describes the *requirement*, and *not* how it failed; for example, it should say "Must be a string" rather than "Is not a string".

Loading…
Cancel
Save