#Optional `@Query` with validation

2 messages · Page 1 of 1 (latest)

ocean siren
#

Any idea how I can perform validation on a @Query if it's present, and ignore it if it's missing. Currently if I do the following:

 async findAll(
    @Query(
      'breedId',
      new ParseUUIDPipe({
        errorHttpStatusCode: HttpStatus.UNPROCESSABLE_ENTITY,
      }),
    )
    breedId?: string,
  ) {
    return this.catService.findAll(breedId);
  }

Omitting the breedId will cause the whole thing to fail validation. I don't want it to fail if it's not present, only if it's present and not a valid uuid.