Skip to content

Commit

Permalink
feat!: renamed ISO8601 regex
Browse files Browse the repository at this point in the history
  • Loading branch information
danielc92 committed Sep 20, 2023
1 parent c2ca984 commit 436e307
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// conservative limit for now
const TENANT_ID_REGEX = new RegExp(/^[a-zA-Z][a-zA-Z-_]{0,98}[a-zA-Z]$/);
const UUIDV4_REGEX = new RegExp(/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
const ISO_DATETIME_REGEX = new RegExp(/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/);
const ISO8601_DATETIME_REGEX = new RegExp(/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/);
const HEX_COLOUR_CODE_REGEX = new RegExp(/^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$/);


module.exports = {
UUIDV4_REGEX,
HEX_COLOUR_CODE_REGEX,
TENANT_ID_REGEX,
ISO_DATETIME_REGEX
ISO8601_DATETIME_REGEX
}
6 changes: 3 additions & 3 deletions index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {
UUIDV4_REGEX,
HEX_COLOUR_CODE_REGEX,
TENANT_ID_REGEX,
ISO_DATETIME_REGEX
ISO8601_DATETIME_REGEX
} = require('.')


Expand Down Expand Up @@ -94,9 +94,9 @@ describe("REGEXES SUITE", () => {
{input: "2023-09-18", output: false},
{input: "2023/09/18", output: false},
{input: "2023-09-18T01:16:54.533", output: false},
])("ISO_DATETIME_REGEX: $input should result in $output", ({input, output}) => {
])("ISO8601_DATETIME_REGEX: $input should result in $output", ({input, output}) => {
expect(
ISO_DATETIME_REGEX.test(input)
ISO8601_DATETIME_REGEX.test(input)
).toEqual(output)
})
})

0 comments on commit 436e307

Please sign in to comment.