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; }