From edd06a6a9451354d6fe322667c18e1bc9e767370 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 6 Aug 2020 12:44:13 +0200 Subject: [PATCH] Include error codes --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 175678f..83b47de 100644 --- a/index.js +++ b/index.js @@ -27,13 +27,13 @@ module.exports = function (protocols) { : null; if (parsedProtocol == null) { - return new ValidationError("Must be a valid URL"); + return new ValidationError("Must be a valid URL", { code: "validatem.is-url.invalid-url" }); } else if (protocolSet != null && !protocolSet.has(parsedProtocol.toLowerCase())) { let validProtocolList = protocols .map((protocol) => protocol.toUpperCase()) .join(", "); - return new ValidationError(`Must be a URL with one of the following protocols: ${validProtocolList} - but got ${parsedProtocol.toUpperCase()} instead`); + return new ValidationError(`Must be a URL with one of the following protocols: ${validProtocolList} - but got ${parsedProtocol.toUpperCase()} instead`, { code: "validatem.is-url.wrong-protocol" }); } else { return parsed; }