_uuid.js 284 B

12345678910
  1. import * as uuid from "uuid";
  2. export function assertUuid(str, which) {
  3. if (!uuid.validate(str)) {
  4. const msg = which !== undefined
  5. ? `Invalid UUID for ${which}: ${str}`
  6. : `Invalid UUID: ${str}`;
  7. throw new Error(msg);
  8. }
  9. return str;
  10. }