2020-04-10 04:04:13 +02:00
|
|
|
import { Check } from 'typeorm';
|
|
|
|
|
|
|
|
export const minValue = 0;
|
|
|
|
export const maxValue = Number.MAX_SAFE_INTEGER;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param column the column which needs to be checked
|
|
|
|
*/
|
2020-11-10 21:39:19 +01:00
|
|
|
export function PercentCheck(column: string): ClassDecorator & PropertyDecorator {
|
2020-04-10 04:04:13 +02:00
|
|
|
return Check(
|
|
|
|
`${column} needs to be between ${minValue} and ${maxValue}`,
|
2021-01-30 22:34:36 +01:00
|
|
|
`${column} >= ${minValue} AND ${column} <= ${maxValue}`,
|
2020-04-10 04:04:13 +02:00
|
|
|
);
|
|
|
|
}
|