10 lines
284 B
JavaScript
10 lines
284 B
JavaScript
import * as uuid from "uuid";
|
|
export function assertUuid(str, which) {
|
|
if (!uuid.validate(str)) {
|
|
const msg = which !== undefined
|
|
? `Invalid UUID for ${which}: ${str}`
|
|
: `Invalid UUID: ${str}`;
|
|
throw new Error(msg);
|
|
}
|
|
return str;
|
|
}
|