Skip to content

Commit

Permalink
feat: Updated sdks/ts/src/utils/isValidUuid4.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Apr 18, 2024
1 parent 4bb2f3b commit fa08200
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sdks/ts/src/utils/isValidUuid4.ts
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;
}

0 comments on commit fa08200

Please sign in to comment.