Files
Picsur/shared/src/util/validate.ts

16 lines
438 B
TypeScript
Raw Normal View History

2022-03-19 21:34:33 +01:00
import { validate } from 'class-validator';
2022-03-27 22:48:10 +02:00
// For some stupid reason, the class-validator library does not have a way to set global defaults
// So now we have to do it this way
2022-03-19 21:34:33 +01:00
export const ValidateOptions = {
disableErrorMessages: true,
forbidNonWhitelisted: true,
forbidUnknownValues: true,
stopAtFirstError: true,
whitelist: true,
};
export const strictValidate = (object: object) =>
validate(object, ValidateOptions);