title: How to validate optional parameters in Nest.js?
body: <p>I'm trying to validate parameters of my <code>PUT</code> <code>users/</code> endpoint but I'd like that all parameters are optional but once the api consumer fill these parameters I'd like to validate them.</p>
  <p>I tried to combined <code>@ApiModelProperty</code> <strong>required false</strong> with validation pipes decorator but validation pipe took over <code>ApiModelProperty</code>
  (pretty normal for sending <strong>400 bad request</strong> <code>HttpException</code>)</p>
  <p>Here is my DTO - <code>usersUpdate.dto.ts</code>:</p>
  <pre><code>import { IsEmail, IsEnum, IsPhoneNumber, IsEmpty } from 'class-validator';
  import { ApiModelProperty } from '@nestjs/swagger';
  import { RoleType } from './role-type.enum';
  
  class UserInfo {
      @ApiModelProperty({ description: 'User firstname', required: false  })
      readonly firstname: string;
  
      @ApiModelProperty({ description: 'User lastname', required: false  })
      readonly lastname: string;
  
      @ApiModelProperty({description: 'User postal address', required: false })
      readonly address: string;
  
      @ApiModelProperty({ description: 'User phone number', required: false  })
      @IsPhoneNumber('FR')
      readonly phone: string;
  
      @ApiModelProperty({ description: 'User siret number', required: false  })
      readonly siret: string;
  }
  
  export class UpdateUserDTO {
      @ApiModelProperty({ description: 'User email address', required: false })
      readonly email: string;
  
      @ApiModelProperty({ description: 'User password', required: false })
      readonly password: string;
  
      @ApiModelProperty({ description: 'User informations', required: false })
      readonly user_info: UserInfo;
  
      @ApiModelProperty({ enum: ['Admin', 'Runner', 'Dispatcher'], description:'User role',  required: false })
      readonly role: RoleType;
  
      @ApiModelProperty({ description: 'User activation token', required: false })
      readonly activationToken: string;
  }
  </code></pre>
  <p>I would like to use and <code>@IsEmail()</code> decorator on email parameter and a <code>@Enum()</code> decorator in role but once I use these decorator the parameter is mandatory.</p>
  <p>Anybody know how to skip this validator if parameters are empty?</p>