All files / src/modules/listings/dto create-listing.input.ts

100% Statements 27/27
100% Branches 0/0
100% Functions 1/1
100% Lines 25/25

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 38 39 40 41 42 43 44 45 46 47 48 49 5011x 11x     11x     11x       11x       11x       11x       11x       11x   11x     11x     11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x  
import { InputType, Field } from '@nestjs/graphql';
import { IsString, IsNumber, IsArray, IsUrl, IsEnum, IsOptional, IsInt, IsBoolean } from 'class-validator';
 
@InputType()
export class CreateListingInput {
  @Field()
  @IsString()
  title!: string;
 
  @Field()
  @IsString()
  description!: string;
 
  @Field()
  @IsNumber()
  price!: number;
 
  @Field()
  @IsNumber()
  addressId!: number;
 
  @Field()
  @IsEnum(['SALE', 'RENT', 'DAILY'])
  transactionType!: 'SALE'|'RENT'|'DAILY';
 
  @Field()
  @IsEnum(['APARTMENT', 'HOUSE', 'COMMERCIAL', 'LAND', 'VILLA', 'STUDIO'])
  type!: 'APARTMENT'|'HOUSE'|'COMMERCIAL'|'LAND'|'VILLA'|'STUDIO';
 
  @Field(() => [String])
  @IsArray()
  @IsUrl({}, { each: true })
  photoUrls!: string[];
 
  // Optional fields to align with DTO
  @Field({ nullable: true }) @IsOptional() @IsNumber() area?: number;
  @Field({ nullable: true }) @IsOptional() @IsInt() rooms?: number;
  @Field({ nullable: true }) @IsOptional() @IsInt() floor?: number;
  @Field({ nullable: true }) @IsOptional() @IsInt() totalFloors?: number;
  @Field({ nullable: true }) @IsOptional() @IsInt() bathrooms?: number;
  @Field({ nullable: true }) @IsOptional() @IsNumber() ceilingHeight?: number;
  @Field({ nullable: true }) @IsOptional() @IsInt() yearBuilt?: number;
  @Field({ nullable: true }) @IsOptional() @IsBoolean() furnished?: boolean;
  @Field({ nullable: true }) @IsOptional() @IsBoolean() renovated?: boolean;
  @Field({ nullable: true }) @IsOptional() @IsBoolean() balcony?: boolean;
  @Field({ nullable: true }) @IsOptional() @IsBoolean() elevator?: boolean;
  @Field({ nullable: true }) @IsOptional() @IsBoolean() internet?: boolean;
  @Field({ nullable: true }) @IsOptional() @IsString() facingSide?: string;
  @Field({ nullable: true }) @IsOptional() @IsString() heating?: 'CENTRAL'|'GAS'|'ELECTRIC'|'OTHER';
}