521bfa3025478a1d7eed7579cb06ddfd9bbf5505
[arvados-workbench2.git] / src / validators / is-uniq-name.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 export const isUniqName = (error: string) => {
6     return sleep(1000).then(() => {
7       if (error.includes("UniqueViolation")) {
8         throw { error: 'Project with this name already exists.' };
9       }
10     });
11   };
12
13 const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));