Swap argument order

master
Sven Slootweg 4 years ago
parent 23a20e9875
commit ea0dbc3ade

@ -6,7 +6,7 @@ const wrapError = require("./");
/*** Simple rules ***/ /*** Simple rules ***/
let rule = wrapError("wrap-error.custom", "This is a custom error message complaining that the value must be a string!", [ isString ]); let rule = wrapError("This is a custom error message complaining that the value must be a string!", "wrap-error.custom", [ isString ]);
console.log(validateValue("hello world", [ rule ])); // hello world console.log(validateValue("hello world", [ rule ])); // hello world
@ -21,7 +21,7 @@ try {
/*** Combinators with properties, and preserving the original errors as well ***/ /*** Combinators with properties, and preserving the original errors as well ***/
let objectRule = wrapError("wrap-error.thingem", "Must be a valid thingem", { let objectRule = wrapError("Must be a valid thingem", "wrap-error.thingem", {
a: [ isString ], a: [ isString ],
b: [ isString ] b: [ isString ]
}, { preserveOriginalErrors: true }); }, { preserveOriginalErrors: true });

@ -17,7 +17,7 @@ function concat(arrays) {
}, arrays[0]); }, arrays[0]);
} }
module.exports = function wrapError(code, message, rules, options = {}) { module.exports = function wrapError(message, code, rules, options = {}) {
if (typeof code !== "string") { if (typeof code !== "string") {
throw new Error(`'code' argument must be a string`); throw new Error(`'code' argument must be a string`);
} else if (typeof message !== "string") { } else if (typeof message !== "string") {

Loading…
Cancel
Save