class-validator-date

Validates date before and after

Usage no npm install needed!

<script type="module">
  import classValidatorDate from 'https://cdn.skypack.dev/class-validator-date';
</script>

README

Description

Custom class-validator for date values. Do validate before and after date value.

usage:

class CreateBillDto {
  @IsString()
  productName: string,
  @IsDateBefore('paymentDate')
  orderDate: string,
  @IsDateAfter('orderDate')
  paymentDate: string,
  @isDateBefore('1972-03-28T23:11:00')
  birth: string;
}

// validate Object
const createBillDto = new CreateBillDto();
const error = await validate(createBillDto);
if (error.length > 0) {
  console.log(error)
}