From ea0dbc3ade0ef8fa75d9472d61b3384ccc9acc1b Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 8 Aug 2020 18:18:41 +0200 Subject: [PATCH] Swap argument order --- example.js | 4 ++-- index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example.js b/example.js index 4eb1d40..a86a5ae 100644 --- a/example.js +++ b/example.js @@ -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 }); diff --git a/index.js b/index.js index aa3b66c..3ac5610 100644 --- a/index.js +++ b/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") {