-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Updated sdks/ts/src/utils/isValidUuid4.ts
- Loading branch information
1 parent
4bb2f3b
commit fa08200
Showing
1 changed file
with
5 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { validate as uuidValidate, version as uuidVersion } from "uuid"; | ||
|
||
/** | ||
* Checks if the input string is a valid UUID v4. | ||
* Validates if the input string is a valid UUID v4. | ||
* This function performs a two-step validation process: | ||
* 1. Validates the format of the UUID using `uuidValidate`. | ||
* 2. Checks that the version of the UUID is 4 using `uuidVersion`. | ||
* @param {string} uuidToTest The string to test for a valid UUID v4. | ||
* @returns {boolean} True if the input is a valid UUID v4, otherwise false. | ||
*/ | ||
export function isValidUuid4(uuidToTest: string): boolean { | ||
// Validate the UUID format and check its version is 4 | ||
return uuidValidate(uuidToTest) && uuidVersion(uuidToTest) === 4; | ||
} |