From 360bfd28c4a276af170a6bd9d660c28893b7d80a Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Mon, 29 Jan 2024 14:16:56 +0100 Subject: [PATCH] fix: domain default tld validation --- lib/types/string.js | 2 +- package.json | 2 +- test/types/string.js | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/types/string.js b/lib/types/string.js index 95ff546d..c86aa391 100755 --- a/lib/types/string.js +++ b/lib/types/string.js @@ -746,7 +746,7 @@ module.exports = Any.extend({ internals.addressOptions = function (options) { if (!options) { - return options; + return internals.tlds || options; // $lab:coverage:ignore$ } // minDomainSegments diff --git a/package.json b/package.json index d1edd1e1..e1942d67 100755 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dependencies": { "@hapi/hoek": "^9.3.0", "@hapi/topo": "^5.1.0", - "@sideway/address": "^4.1.4", + "@sideway/address": "^4.1.5", "@sideway/formula": "^3.0.1", "@sideway/pinpoint": "^2.0.0" }, diff --git a/test/types/string.js b/test/types/string.js index cf293008..64c65ee6 100755 --- a/test/types/string.js +++ b/test/types/string.js @@ -1323,7 +1323,8 @@ describe('string', () => { type: 'string.domain', context: { value: '"example.com', label: 'value' } }], - ['mail@example.com', false, '"value" must contain a valid domain name'] + ['mail@example.com', false, '"value" must contain a valid domain name'], + ['joi.dev.whatevertldiwant', false, '"value" must contain a valid domain name'] ]); }); @@ -1465,7 +1466,8 @@ describe('string', () => { type: 'string.email', context: { value: '123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345.toolong.com', invalids: ['123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345.toolong.com'], label: 'value' } }], - ['foo@bar%2ecom', false, '"value" must be a valid email'] + ['foo@bar%2ecom', false, '"value" must be a valid email'], + ['invalid_tlds@email.ccc', false, '"value" must be a valid email'] ]); });