The last validation library you'll ever need.

While Validatem is suitable for any sort of validation, this unique combination of features and design choices makes it especially useful for validating arguments in the public API of libraries, unlike other validation libraries!

For example, you might write something like the following (from the icssify library):

1
2
3
4
5
6
7
8
9
10
11
12
13
module.exports = function (browserify, options) {
    validateArguments(arguments, {
        browserify: required ,
        options: allowExtraProperties({
            mode: oneOf([ "local", "global" ]),
            before: arrayOf([ required, isPostcssPlugin ]),
            after: arrayOf([ required, isPostcssPlugin ]),
            extensions: arrayOf([ required, isString ])
        })
    });

    // Implementation code goes here ...
};

And calling it like so:

1
2
3
4
5
icssify(undefined, {
    mode: "nonExistentMode",
    before: [ NaN ],
    unspecifiedButAllowedOption: true
})

... would then produce an error like this:

1
2
3
4
ValidationError: One or more validation errors occurred:
 - At browserify: Required value is missing
 - At options -> mode: Must be one of: 'local', 'global'
 - At options -> before -> 0: Must be a PostCSS plugin

Work in progress!

This site (and the library) is still being actively worked on. Parts of the documentation will be missing - but by the time Validatem reaches 1.0.0, it will all be there!