1 | /*
|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
3 | Author Tobias Koppers @sokra
|
4 | */
|
5 |
|
6 | ;
|
7 |
|
8 | const memoize = require("./memoize");
|
9 |
|
10 | const getValidate = memoize(() => require("schema-utils").validate);
|
11 |
|
12 | const createSchemaValidation = (check = v => false, getSchema, options) => {
|
13 | getSchema = memoize(getSchema);
|
14 | return value => {
|
15 | if (!check(value)) {
|
16 | getValidate()(getSchema(), value, options);
|
17 | }
|
18 | };
|
19 | };
|
20 |
|
21 | module.exports = createSchemaValidation;
|