Wrap rules in context that instructs to avoid parsing

master
Sven Slootweg 4 years ago
parent 02eaa5309d
commit 81cdaeb665

@ -2,12 +2,16 @@
const combinator = require("@validatem/combinator");
const validationResult = require("@validatem/validation-result");
const withContext = require("@validatem/with-context");
// TODO: Document that this passes on context
module.exports = function ignoreResult(rules) {
// TODO: Document the convention of `parseIntoResult`, and that parsing validators can take this from the context to determine whether the result is going to be ignored (which means it may not have to parse in the first place)
let rulesWithParsingDisabled = withContext(rules, { parseIntoResult: false });
return combinator((value, applyValidators, context) => {
let result = applyValidators(value, rules, context);
let result = applyValidators(value, rulesWithParsingDisabled, context);
return validationResult({
errors: result.errors,

@ -17,6 +17,7 @@
},
"dependencies": {
"@validatem/combinator": "^0.1.2",
"@validatem/validation-result": "^0.1.2"
"@validatem/validation-result": "^0.1.2",
"@validatem/with-context": "^0.1.2"
}
}

@ -21,7 +21,7 @@
"@validatem/virtual-property" "^0.1.0"
default-value "^1.0.0"
"@validatem/combinator@^0.1.0", "@validatem/combinator@^0.1.2":
"@validatem/combinator@^0.1.0", "@validatem/combinator@^0.1.1", "@validatem/combinator@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@validatem/combinator/-/combinator-0.1.2.tgz#eab893d55f1643b9c6857eaf6ff7ed2a728e89ff"
integrity sha512-vE8t1tNXknmN62FlN6LxQmA2c6TwVKZ+fl/Wit3H2unFdOhu7SZj2kRPGjAXdK/ARh/3svYfUBeD75pea0j1Sw==
@ -128,6 +128,13 @@
resolved "https://registry.yarnpkg.com/@validatem/virtual-property/-/virtual-property-0.1.0.tgz#880540dfd149f98ecf1095d93912e34443381fe4"
integrity sha512-JUUvWtdqoSkOwlsl20oB3qFHYIL05a/TAfdY4AJcs55QeVTiX5iI1b8IoQW644sIWWooBuLv+XwoxjRsQFczlQ==
"@validatem/with-context@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@validatem/with-context/-/with-context-0.1.2.tgz#3645c04897664f70995104961277e07b61b4f615"
integrity sha512-noAWf4CsmU+BCz+KOg3GPq9+R9BQLWOQnOgWVfkYHFdLnnbLhl8w/ONdzvFzUYGHIZGKZwsWVCp+Kwz/tAfMnA==
dependencies:
"@validatem/combinator" "^0.1.1"
as-expression@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/as-expression/-/as-expression-1.0.0.tgz#7bc620ca4cb2fe0ee90d86729bd6add33b8fd831"

Loading…
Cancel
Save