Skip to content

Commit 08ccc99

Browse files
feat: new regex for alphanum dash lowercase (#1117)
1 parent d94b232 commit 08ccc99

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/regex/src/__tests__/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
alphanumUnderscoreDash,
1010
alphanumUnderscoreDollarDash,
1111
alphanumdash,
12+
alphanumdashLowercase,
1213
alphanumdashdots,
1314
alphanumdashdotsorempty,
1415
alphanumdashdotsspaces,
@@ -318,6 +319,7 @@ describe('@regex', () => {
318319

319320
describe('alphanumLowercase', () => {
320321
test.each([
322+
[alphanumdashText, false],
321323
[asciiLetters, false],
322324
[asciiLowercase, true],
323325
[asciiUppercase, false],
@@ -335,6 +337,26 @@ describe('@regex', () => {
335337
})
336338
})
337339

340+
describe('alphanumdashLowercase', () => {
341+
test.each([
342+
[asciiLetters, false],
343+
[asciiLowercase, true],
344+
[alphanumdashText, true],
345+
[asciiUppercase, false],
346+
[digitsTest, true],
347+
[emailTest, false],
348+
[octdigits, true],
349+
[hexdigits, false],
350+
[printable, false],
351+
[punctuation, false],
352+
[whitespace, false],
353+
[cronTest, false],
354+
[macAddress1, false],
355+
])('should match regex %s to be %s', (string, expected) => {
356+
expect(alphanumdashLowercase.test(string)).toBe(expected)
357+
})
358+
})
359+
338360
describe('alphanumSpacesDotsUnderscoreDash', () => {
339361
test.each([
340362
[asciiLetters, true],

packages/regex/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const alphanumdashorempty = /^$|^[a-zA-Z0-9-]*$/
1010
export const alphanumdashspaces = /^[a-zA-Z0-9-\s]*$/
1111
export const alphanumdots = /^[a-zA-Z0-9.]*$/
1212
export const alphanumLowercase = /^[a-z0-9]+$/
13+
export const alphanumdashLowercase = /^[a-z0-9-]+$/
1314
export const alphanumSpacesDotsUnderscoreDash = /^[a-zA-Z0-9-.\s_]*$/
1415
export const alphanumUnderscoreDash = /^[a-zA-Z0-9_-]*$/
1516
export const alphanumUnderscoreDollarDash = /^[a-zA-Z0-9_$-]*$/

0 commit comments

Comments
 (0)