Documentation for this module has not been fully written yet. By the time it reaches 1.0.0, it will have full documentation.
In the meantime, check out the
example.js file in the repository for a usage demonstration.
A partial draft for the future documentation is below:
Used for specifying Validatem 'combinators', ie. validators that need to manually control what rules to apply to what (sub-)values. Typically used for validating data structures which have multiple internal values to validate, like in the
arrayOf(...) combinator, or when validation should be conditional, like in the
Note that this package doesn't actually really do anything. It just produces a special versioned object type, that's recognized (and handled accordingly) by the Validatem core; which will 'inject' the
applyValidators function into your combinator, which you can use to apply a set of validation rules to a value.
This slightly odd dependency-injection design exists because
applyValidators is tightly interwoven with the rest of the Validatem core, and it's not really possible to extract it out into a separate package without basically moving all of the core into it, defeating the point of packaging this separately.
Why is this a separate package?
One of the design goals of Validatem is to minimize how much complexity and code you're adding to your project. Because of that, all of the plumbing used by validators and combinators is packaged as granularly as possible. This prevents the situation where you have 20 copies of the entire Validatem core floating around in your project, just because different validators happen to depend on slightly different versions.
By having several small 'plumbing' packages, validators never need to depend on
@validatem/core, but only on the specific bits of plumbing that they need.