Take this code for example
export enum Options {
USERS = 'users',
ADMINS = 'admins',
}
export class QueryDTO {
@IsDefined()
@Validate(IsValidOptionType)
readonly filter: Options;
@IsOptional()
@Transform((value) => Number(value))
readonly userId: string;
@IsOptional()
@Transform((value) => Number(value))
readonly adminId: string;
}
Goal is to only allow the query to run by sets, meaning, if filter = users then userId needs to exist, if filters = admins then adminId needs to exist, and ignore the other params.
Whats a good way to validate this? I would really love something like this
@Validate(Dependency['users'])
@IsOptional()
@Transform((value) => Number(value))
readonly userId: string;