diff --git a/src/lib/isFQDN.js b/src/lib/isFQDN.js index 4a04cf34e..884d1dd6f 100644 --- a/src/lib/isFQDN.js +++ b/src/lib/isFQDN.js @@ -32,7 +32,7 @@ export default function isFQDN(str, options) { return false; } - if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { + if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { return false; } diff --git a/test/validators.js b/test/validators.js index af2d21b2e..604072dab 100644 --- a/test/validators.js +++ b/test/validators.js @@ -1309,7 +1309,18 @@ describe('Validators', () => { ], }); }); - + it('should validate FQDN with required allow_trailing_dot, allow_underscores and allow_numeric_tld options', () => { + test({ + validator: 'isFQDN', + args: [ + { allow_trailing_dot: true, allow_underscores: true, allow_numeric_tld: true }, + ], + valid: [ + 'abc.efg.g1h.', + 'as1s.sad3s.ssa2d.', + ], + }); + }); it('should validate alpha strings', () => { test({ validator: 'isAlpha',