16 lines
546 B
TypeScript
16 lines
546 B
TypeScript
import { Check } from 'typeorm';
|
|
|
|
export const minValue = 0;
|
|
export const maxValue = Number.MAX_SAFE_INTEGER;
|
|
|
|
/**
|
|
* @param column the column which needs to be checked
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/ban-types -- the type would be "(classOrObject: object, propertyName: string) => object" but typeorm does not provide it
|
|
export function PercentCheck(column: string): Function {
|
|
return Check(
|
|
`${column} needs to be between ${minValue} and ${maxValue}`,
|
|
`${column} >= ${minValue} AND ${column} <= ${maxValue}`
|
|
);
|
|
}
|