-
Notifications
You must be signed in to change notification settings - Fork 3
/
validation-errors.ts
81 lines (52 loc) · 3.51 KB
/
validation-errors.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* SudoSOS back-end API service.
* Copyright (C) 2024 Study association GEWIS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license
*/
/**
* This is the module page of the validation-errors.
*
* @module internal/spec/validation-errors
*/
import { ValidationError } from '../../../helpers/specification-validation';
export const INVALID_PRODUCT_ID = (id: number) => new ValidationError(`ID (${id}) is not a valid product id.`);
export const INVALID_PRODUCT_PRICE = () => new ValidationError('Price must be greater than zero');
export const INVALID_CONTAINER_ID = (id: number) => new ValidationError(`ID (${id}) is not a valid container id.`);
export const CONTAINER_VALIDATION_FAIL = () => new ValidationError('Container validation failed:');
export const PRODUCT_VALIDATION_FAIL = () => new ValidationError('Product validation failed:');
export const INVALID_DATE = () => new ValidationError('is not a valid Date.');
export const INVALID_DATE_DURATION = () => new ValidationError('End Date must be after the Start Date.');
export const INVALID_USER_ID = () => new ValidationError('must exist.');
export const INVALID_ORGAN_ID = () => new ValidationError('Owner must be of type ORGAN.');
export const ZERO_LENGTH_STRING = () => new ValidationError('must be a non-zero length string.');
export const MAX_STRING_SIZE = () => new ValidationError('is too long.');
export const DUPLICATE_TOKEN = () => new ValidationError('token already in use.');
export const INVALID_USER_TYPE = () => new ValidationError('type is not a valid UserType.');
export const INVALID_ACTIVE_USER_ID = () => new ValidationError('must exist and be active.');
export const INVALID_TRANSACTION_OWNER = () => new ValidationError('Not all transactions have the correct owner.');
export const INVALID_TRANSACTION_IDS = () => new ValidationError('Not all transaction IDs are valid.');
export const NO_TRANSACTION_IDS = () => new ValidationError('No transaction IDs provided.');
export const INVALID_INVOICE_ID = () => new ValidationError('Invoice with this ID does not exist.');
export const INVOICE_IS_DELETED = () => new ValidationError('Invoice is deleted.');
export const INVOICE_IS_PAID = () => new ValidationError('Invoice is paid.');
export const SAME_INVOICE_STATE = () => new ValidationError('Update state is same as current state.');
export const SUBTRANSACTION_ALREADY_INVOICED = (ids: number[]) => new ValidationError(`SubTransactions ${ids}: have already been invoiced.`);
export const INVALID_PIN = () => new ValidationError('PIN is not 4 numbers');
export const WEAK_PASSWORD = () => new ValidationError('Password not strong enough.');
export const EMPTY_ARRAY = () => new ValidationError('is empty.');
export const INVALID_ROLE_ID = (id: number) => new ValidationError(`Role with ID ${id} does not exist.`);
export const INVALID_CUSTOM_ROLE_ID = (id: number) => new ValidationError(`Role with ID ${id} is a system default role.`);