import { applyDecorators } from '@nestjs/common';
import { ValidateIf } from 'class-validator';

export function IsOptional() {
  const validateIf = ValidateIf((obj: any, value) => {
    if (typeof value === 'undefined') return false;

    return true;
  });

  return applyDecorators(validateIf);
}
