Yo, i have store application with nestjs, i need validate mongo id, which is pass by query, the problem is that i also pass and search query. I write pipe which validate all values, and exclude this search query
@Injectable()
export class ValidationObjectId implements PipeTransform {
transform(value: UniqueId, metadata: ArgumentMetadata) {
if (
!Types.ObjectId.isValid(value) &&
metadata.data !== "searchString"
) {
throw new BadRequestException("Неверный параметр запроса");
}
return value;
}
}
But this code not reusable for other case. I want get some examples, how i can do this
Aucun commentaire:
Enregistrer un commentaire