All files / src/modules/open-houses/dto create-open-house.dto.ts

100% Statements 17/17
75% Branches 6/8
100% Functions 4/4
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 3812x 12x 12x 12x   12x 24x 24x 24x       12x           2x   12x             2x   12x           11x 12x  
import { IsDate, IsNotEmpty, IsOptional, IsInt, Min, MaxDate, MinDate } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { Field, InputType, Int } from '@nestjs/graphql';
 
const oneYearAhead = () => {
  const d = new Date();
  d.setFullYear(d.getFullYear() + 1);
  return d;
};
 
@InputType()
export class CreateOpenHouseDto {
  @ApiProperty({ description: 'Start time (UTC ISO string)', format: 'date-time' })
  @IsDate()
  @IsNotEmpty()
  @MinDate(new Date())
  @MaxDate(oneYearAhead())
  @Type(() => Date)
  @Field()
  startTime!: Date;
 
  @ApiProperty({ description: 'End time (UTC ISO string)', format: 'date-time' })
  @IsDate()
  @IsNotEmpty()
  @MinDate(new Date())
  @MaxDate(oneYearAhead())
  @Type(() => Date)
  @Field()
  endTime!: Date;
 
  @ApiPropertyOptional({ minimum: 1 })
  @IsOptional()
  @IsInt()
  @Min(1)
  @Field(() => Int, { nullable: true })
  maxVisitors?: number;
}