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
65 changes: 34 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# builds
build
dist
.rpt2_cache

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Optional eslint cache
.eslintcache

coverage

storybook-static
.terraform
terraform

# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# builds
build
dist
.rpt2_cache

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Optional eslint cache
.eslintcache

coverage

storybook-static
.terraform
terraform

# Ignore vs folder
.vs

.npmrc
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- `isValidGuid` unwanted behaviour which was returning false for Guid sequentially generated by following Microsoft EntityFramework
- maxGuid (`ffffffff-ffff-ffff-ffff-ffffffffffff`) is now recognized as valid Guid

## [1.3.0] - 2025-04-10

### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/lib/guid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ describe("guid tests", () => {
[" ", false],
["507956c7-30b3-4401-9800-e5e7f8f3276X", false],
["507956c7-30b3-4401-9800-e5e7f8f32761", true],
["f094d99a-347e-4fe5-eea2-08dbc5deb2a0", true],
[newGuid(), true],
[emptyGuid, true],
["3B467B14-CD99-4199-8E35-82B3C37182BA", true],
// MAX not recognized as guid > https://github.com/uuidjs/uuid/pull/714
["ffffffff-ffff-ffff-ffff-ffffffffffff", false],
["ffffffff-ffff-ffff-ffff-ffffffffffff", true],
])("isValidGuid", (value, expected) => {
expect(isValidGuid(value)).toBe(expected);
});
Expand Down
5 changes: 3 additions & 2 deletions src/lib/guid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export function newGuid() {
}

/**
* Check whether a string it is a valid Guid (version 4 UUID)
* Check whether a string it is a valid Guid
* @param str The string to test whether it is a valid Guid
* @returns A value indicating whether the string is a valid Guid
*/
export function isValidGuid(str: string) {
return uuid.validate(str);
const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
return typeof str === "string" && regex.test(str);
}

/**
Expand Down