Skip to content

Commit

Permalink
fix: add hexa regex (#130)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Audebert <vaudebert@online.net>
  • Loading branch information
vincentaudebert and Vincent Audebert authored Apr 15, 2021
1 parent 56dba05 commit a67e2e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/regex/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
digits,
email,
fourDigitsCode,
hexadecimal,
macAddress,
phone,
sixDigitsCode,
Expand Down Expand Up @@ -558,4 +559,26 @@ describe('@regex', () => {
expect(url.test(string)).toBe(result)),
)
})

describe('hexadecimal', () => {
;[
[asciiLetters, false],
[asciiLowercase, false],
[asciiUppercase, false],
[digitsTest, true],
[emailTest, false],
[octdigits, true],
[fourDigitsTest, true],
[printable, false],
[phoneTest, false],
[sixDigitsCodeTest, true],
[punctuation, false],
[whitespace, false],
[cronTest, false],
[hexdigits, true],
].forEach(([string, result]) =>
it(`should match regex ${string} to be ${result}`, () =>
expect(hexadecimal.test(string)).toBe(result)),
)
})
})
1 change: 1 addition & 0 deletions packages/regex/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export const phone = /^\+[0-9]*/
export const spaces = /^\s*$/
export const sixDigitsCode = /^[0-9]{6}$/
export const url = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/
export const hexadecimal = /^[0-9a-fA-F]+$/

0 comments on commit a67e2e6

Please sign in to comment.