Skip to content

Commit a67e2e6

Browse files
vincentaudebertVincent Audebert
andauthored
fix: add hexa regex (#130)
Co-authored-by: Vincent Audebert <[email protected]>
1 parent 56dba05 commit a67e2e6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/regex/src/__tests__/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
digits,
1919
email,
2020
fourDigitsCode,
21+
hexadecimal,
2122
macAddress,
2223
phone,
2324
sixDigitsCode,
@@ -558,4 +559,26 @@ describe('@regex', () => {
558559
expect(url.test(string)).toBe(result)),
559560
)
560561
})
562+
563+
describe('hexadecimal', () => {
564+
;[
565+
[asciiLetters, false],
566+
[asciiLowercase, false],
567+
[asciiUppercase, false],
568+
[digitsTest, true],
569+
[emailTest, false],
570+
[octdigits, true],
571+
[fourDigitsTest, true],
572+
[printable, false],
573+
[phoneTest, false],
574+
[sixDigitsCodeTest, true],
575+
[punctuation, false],
576+
[whitespace, false],
577+
[cronTest, false],
578+
[hexdigits, true],
579+
].forEach(([string, result]) =>
580+
it(`should match regex ${string} to be ${result}`, () =>
581+
expect(hexadecimal.test(string)).toBe(result)),
582+
)
583+
})
561584
})

packages/regex/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ export const phone = /^\+[0-9]*/
2424
export const spaces = /^\s*$/
2525
export const sixDigitsCode = /^[0-9]{6}$/
2626
export const url = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/
27+
export const hexadecimal = /^[0-9a-fA-F]+$/

0 commit comments

Comments
 (0)