class-validator-extended - v4.2.0
    Preparing search index...

    Function Optional

    • Only validates the given value if it is not undefined.

      This is similar to the built-in @IsOptional except that it does not allow null. Note that this validator does not work as expected with { each: true } (because it is based on @ValidateIf which does not either).

      // Ensure the value is a string or undefined (but not null).
      @Optional()
      @IsString()
      value?: string

      Parameters

      • Optionaloptions: ValidationOptions

        Generic class-validator options.

      Returns PropertyDecorator