I have created a custom validator that others might find useful as well.
It covers the use case of a property not being empty, null or undefined.
export type ValidatorOptionType = {
message?: string;
}
export const IsNotEmpty = ({ message = 'Property must not be empty' }: ValidatorOptionType = {}): PropertyDecorator =>
createDecorator(
(prop: unknown) => prop !== '' && prop !== null && prop !== undefined,
{ errorMessage: message, constraints: [] }
);
Here is an example of how to use it:
@IsNotEmpty({ message: MSG_VALIDATION.required })
initials: string;
I have created a custom validator that others might find useful as well.
It covers the use case of a property not being empty, null or undefined.
Here is an example of how to use it: