I have been using the class-validator decorator library to validate dto objects and would like to create a domain whitelist for the @IsEmail decorator. The library includes a @Contains decorator, which can be used for a single string (seed), but I would like to input an array of valid strings instead. Is this possible?
current
@Contains('@mydomain.com')
@IsEmail()
public email: string;
desired
@Contains(['@mydomain, @yourdomain, @wealldomain, @fordomain'])
@IsEmail()
public email: string;
If this is not possible, I would appreciate any direction on how to implement a custom decorator which serves this purpose.
Thanks.
@ArrayContains(values: any[])?