Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/regex/src/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
alphanumdashdotsspaces,
alphanumdashorempty,
alphanumdashspaces,
alphanumdashunderscoredotsspacesparenthesis,
alphanumdots,
ascii,
backupKey,
Expand All @@ -40,6 +41,7 @@ import {
} from '..'

const alphanumdashdotsText = 'testwithdashdots-.'
const alphanumdashunderscoredotsparenthesisText = 'testwithdashdots-_. ()'
const alphanumdashText = 'testwithdash-'
const asciiLetters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
const asciiLowercase = 'abcdefghijklmnopqrstuvwxyz'
Expand Down Expand Up @@ -254,6 +256,30 @@ describe('@regex', () => {
})
})

describe('alphanumdashunderscoredotsspacesparenthesis', () => {
test.each([
[alphanumdashText, true],
[alphanumdashdotsText, true],
[alphanumdashunderscoredotsparenthesisText, true],
[asciiLetters, true],
[asciiLowercase, true],
[asciiUppercase, true],
[digitsTest, true],
[emailTest, false],
[octdigits, true],
[hexdigits, true],
[printable, false],
[punctuation, false],
[whitespace, true],
[cronTest, false],
[macAddress1, false],
])('should match regex %s to be %s', (string, expected) => {
expect(alphanumdashunderscoredotsspacesparenthesis.test(string)).toBe(
expected,
)
})
})

describe('alphanumdashorempty', () => {
test.each([
[alphanumdashText, true],
Expand Down
3 changes: 3 additions & 0 deletions packages/regex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export const alphanumdash = /^[a-zA-Z0-9-]*$/
export const alphanumdashdots = /^[a-zA-Z0-9-.]*$/
export const alphanumdashdotsorempty = /^$|^[a-zA-Z0-9-.]*$/
export const alphanumdashdotsspaces = /^[a-zA-Z0-9-.\s]*$/
export const alphanumdashunderscoredotsspacesparenthesis =
/^[a-zA-Z0-9-_.()\s]*$/

export const alphanumdashorempty = /^$|^[a-zA-Z0-9-]*$/
export const alphanumdashspaces = /^[a-zA-Z0-9-\s]*$/
export const alphanumdots = /^[a-zA-Z0-9.]*$/
Expand Down