Swap argument order
This commit is contained in:
parent
23a20e9875
commit
ea0dbc3ade
|
@ -6,7 +6,7 @@ const wrapError = require("./");
|
|||
|
||||
/*** 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
|
||||
|
||||
|
@ -21,7 +21,7 @@ try {
|
|||
|
||||
/*** 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 ],
|
||||
b: [ isString ]
|
||||
}, { preserveOriginalErrors: true });
|
||||
|
|
2
index.js
2
index.js
|
@ -17,7 +17,7 @@ function concat(arrays) {
|
|||
}, arrays[0]);
|
||||
}
|
||||
|
||||
module.exports = function wrapError(code, message, rules, options = {}) {
|
||||
module.exports = function wrapError(message, code, rules, options = {}) {
|
||||
if (typeof code !== "string") {
|
||||
throw new Error(`'code' argument must be a string`);
|
||||
} else if (typeof message !== "string") {
|
||||
|
|
Loading…
Reference in a new issue