Getting started

How does Validatem work?

As validation libraries go, Validatem is a little different. For example, unlike Joi (where every validator is a chained method) or checkit (where every validator is a string name), a validator in Validatem is just a function that receives the to-be-validated value as an argument. That function can do a few different things:

Importantly, you can write these functions yourself, and custom validators - whether written by you or by someone else - are on equal footing with the 'official' validators. They are just as easy to use, and just as easy to combine. In fact, all of the official validators are packaged as if they were third-party packages!

Validating a value or a function's arguments, then, is just a matter of calling validateValue, validateArguments, or validateOptions with the desired validation schema. Either it will pass (and return the validated value, optionally transformed), or it will fail and throw an AggregrateValidationError with a clear description of what's wrong:

TODO: Insert error example here

Transforming values

TODO: explain why defaultTo etc. are useful, self-documenting

Combining (composing) validators

TODO: show array syntax TODO: show why wrapError can be useful

TODO: explain how linters can interfere? TODO: explain how either can be used like a match statement, like is done in raqb with wrapping