validate-glob-opts

Validate node-glob options
validateGlobOpts({
sync: true,
mark: '/',
caches: {}
});
Installation
Use npm.
npm install validate-glob-opts
API
const validateGlobOpts = require('validate-glob-opts');
validateGlobOpts(obj)
obj: Object
(glob
options)
Return: Array
of errors
It strictly validates glob
options, for example,
- It disallows the deprecated
sync
option to receive any values. - It disallows String options e.g.
cwd
to receive non-string values. - It disallows Boolean options e.g.
stat
to receive non-boolean values. - It disallows Object options e.g.
symlinks
to receive non-object values. - It invalidates probably typoed option names e.g.
symlink
.
Then, it returns the validation result as an array of error objects.
const validateGlobOpts = require('validate-glob-opts');
const ok = {
root: '/foo/bar/',
nodir: true,
ignore: ['path1', 'path2'],
symlinks: {}
};
validateGlobOpts(ok);
const notOk = {
root: Buffer.from('Hi'),
nodir: NaN,
ignore: ['path1', 1],
symlink: {}
};
const results = validateGlobOpts(ok);
results.length;
results[0];
results[1];
results[2];
results[3];
License
Copyright (c) 2017 Shinnosuke Watanabe
Licensed under the MIT License.