Skip to content

Commit c548cba

Browse files
authored
Merge branch 'main' into changeset-release/main
2 parents 6388175 + be2d1a8 commit c548cba

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.changeset/lovely-bags-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@scaleway/regex": patch
3+
---
4+
5+
Add new regex underscore uppercase

packages/regex/src/__tests__/index.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
alpha,
88
alphaDashes,
99
alphaLowercase,
10+
alphaUpperUnderscore,
1011
alphanum,
1112
alphanumDash,
1213
alphanumDashDots,
@@ -53,6 +54,7 @@ import {
5354
const alphanumDashDotsText = 'testwithdashdots-.'
5455
const alphanumDashUnderscoreDotsParenthesisText = 'testwithdashdots-_. ()'
5556
const alphanumDashText = 'testwithdash-'
57+
const uppercaseUnderscoreText = 'ASTT_GGF'
5658
const asciiLetters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
5759
const nonAsciiLetters =
5860
'ÀÁÂÃÄÅàáâãäåÇçÈÉÊËèéêëÌÍÎÏìíîïÑñÒÓÔÕÖòóôõöÙÚÛÜùúûüÝýÿĀāĈĉĜĝĤĥĴĵŜŝŴŵŶŷāăąǎćĉčċđēĕėęǝğōŏőǒśŝşšūŭůűǔüźżž'
@@ -378,6 +380,27 @@ describe('@regex', () => {
378380
expect(alphanumDots.test(string)).toBe(expected)
379381
})
380382
})
383+
describe('alphaUpperUnderscore', () => {
384+
test.each([
385+
[alphanumDashText, false],
386+
[uppercaseUnderscoreText, true],
387+
[alphanumDashDotsText, false],
388+
[asciiLetters, false],
389+
[asciiLowercase, false],
390+
[asciiUppercase, true],
391+
[digitsTest, false],
392+
[emailTest, false],
393+
[octdigits, false],
394+
[hexdigits, false],
395+
[printable, false],
396+
[punctuation, false],
397+
[whitespace, false],
398+
[cronTest, false],
399+
[macAddress1, false],
400+
])('should match regex %s to be %s', (string, expected) => {
401+
expect(alphaUpperUnderscore.test(string)).toBe(expected)
402+
})
403+
})
381404

382405
describe('alphanumLowercase', () => {
383406
test.each([

packages/regex/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const alphanumDashDotsOrEmpty = /^$|^[a-zA-Z0-9-.]*$/
99
export const alphanumDashDotsSpaces = /^[a-zA-Z0-9-.\s]*$/
1010
export const alphanumDashLowercase = /^[a-z0-9-]+$/
1111
export const alphanumDashSpaces = /^[a-zA-Z0-9-\s]*$/
12+
export const alphaUpperUnderscore = /^[A-Z_]+$/
13+
1214
export const alphanumDashOrEmpty = /^$|^[a-zA-Z0-9-]*$/
1315
export const alphanumDashUnderscoreDots = /^[a-zA-Z0-9-._]*$/
1416
export const alphanumDashUnderscore = /^[a-zA-Z0-9-_]*$/

0 commit comments

Comments
 (0)