diff --git a/src/lib/isLocale.js b/src/lib/isLocale.js index ec84c8fce..72566bb38 100644 --- a/src/lib/isLocale.js +++ b/src/lib/isLocale.js @@ -30,7 +30,7 @@ const region = '([A-Za-z]{2}|\\d{3})'; = 5*8alphanum ; registered variants / (DIGIT 3alphanum) */ -const variant = '([A-Za-z0-9]{5,8}|(\\d[A-Z-a-z0-9]{3}))'; +const variant = '([A-Za-z0-9]{5,8}|(\\d[A-Za-z0-9]{3}))'; /* = DIGIT ; 0 - 9 diff --git a/test/validators.test.js b/test/validators.test.js index 98d2a12ff..a53747c85 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -5714,6 +5714,14 @@ describe('Validators', () => { }); }); + it('should reject hyphens within digit-leading locale variants', () => { + test({ + validator: 'isLocale', + valid: ['de-CH-1901', 'sl-rozaj-biske-1994', 'de_CH_1901'], + invalid: ['de-CH-190-', 'en-1--a', 'en-1-a-', 'en-1---'], + }); + }); + it('should validate strings by byte length (deprecated api)', () => { test({ validator: 'isByteLength',