Skip to content

Commit 999da76

Browse files
refactor(common): simplify isUUID helper function
1 parent 4624a24 commit 999da76

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

packages/common/utils/assert-string.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/common/utils/is-uuid.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertString } from './assert-string';
1+
import { BadRequestException } from '../exceptions';
22

33
const uuid = {
44
3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
@@ -8,7 +8,9 @@ const uuid = {
88
};
99

1010
export function isUUID(str: any, version = 'all') {
11-
assertString(str);
11+
if (typeof str !== 'string') {
12+
throw new BadRequestException('The value passed as UUID is not a string');
13+
}
1214
const pattern = uuid[version];
1315
return pattern && pattern.test(str);
1416
}

0 commit comments

Comments
 (0)