agent and category Dto creation
This commit is contained in:
128
src/agents/dto/create-agent-profile.dto.ts
Normal file
128
src/agents/dto/create-agent-profile.dto.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
IsArray,
|
||||
IsInt,
|
||||
IsUrl,
|
||||
IsUUID,
|
||||
MinLength,
|
||||
MaxLength,
|
||||
Min,
|
||||
Max,
|
||||
} from 'class-validator';
|
||||
|
||||
export class CreateAgentProfileDto {
|
||||
@ApiProperty({ example: 'John' })
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(100)
|
||||
firstName: string;
|
||||
|
||||
@ApiProperty({ example: 'Doe' })
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(100)
|
||||
lastName: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '+1234567890' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(20)
|
||||
phone?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Experienced real estate agent...' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(2000)
|
||||
bio?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Top Real Estate Agent in California' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(200)
|
||||
headline?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Los Angeles' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
city?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'California' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
state?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'USA' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
country?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '123 Main St' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(200)
|
||||
address?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '90001' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(20)
|
||||
zipCode?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 10 })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@Max(100)
|
||||
yearsOfExperience?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: 'LIC-12345' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(50)
|
||||
licenseNumber?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'ABC Realty' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(200)
|
||||
companyName?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'https://mywebsite.com' })
|
||||
@IsOptional()
|
||||
@IsUrl()
|
||||
website?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'https://facebook.com/johndoe' })
|
||||
@IsOptional()
|
||||
@IsUrl()
|
||||
facebookUrl?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'https://twitter.com/johndoe' })
|
||||
@IsOptional()
|
||||
@IsUrl()
|
||||
twitterUrl?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'https://linkedin.com/in/johndoe' })
|
||||
@IsOptional()
|
||||
@IsUrl()
|
||||
linkedinUrl?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'https://instagram.com/johndoe' })
|
||||
@IsOptional()
|
||||
@IsUrl()
|
||||
instagramUrl?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: ['uuid-1', 'uuid-2'],
|
||||
description: 'Array of specialization IDs',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsUUID('4', { each: true })
|
||||
specializationIds?: string[];
|
||||
}
|
||||
3
src/agents/dto/index.ts
Normal file
3
src/agents/dto/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './create-agent-profile.dto';
|
||||
export * from './update-agent-profile.dto';
|
||||
export * from './search-agents.dto';
|
||||
83
src/agents/dto/search-agents.dto.ts
Normal file
83
src/agents/dto/search-agents.dto.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsUUID,
|
||||
IsArray,
|
||||
Min,
|
||||
Max,
|
||||
} from 'class-validator';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
|
||||
export class SearchAgentsDto {
|
||||
@ApiPropertyOptional({ example: 'John' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
search?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Los Angeles' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
city?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'California' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
state?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'USA' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
country?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'uuid-of-category' })
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
categoryId?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: ['uuid-1', 'uuid-2'],
|
||||
description: 'Filter by specialization IDs',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsUUID('4', { each: true })
|
||||
@Transform(({ value }) => (typeof value === 'string' ? [value] : value))
|
||||
specializationIds?: string[];
|
||||
|
||||
@ApiPropertyOptional({ example: true })
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => value === 'true' || value === true)
|
||||
@IsBoolean()
|
||||
isVerified?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ example: 1, default: 1 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
page?: number = 1;
|
||||
|
||||
@ApiPropertyOptional({ example: 10, default: 10 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
limit?: number = 10;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 'createdAt',
|
||||
enum: ['createdAt', 'averageRating', 'totalReviews', 'firstName'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
sortBy?: string = 'createdAt';
|
||||
|
||||
@ApiPropertyOptional({ example: 'desc', enum: ['asc', 'desc'] })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
sortOrder?: 'asc' | 'desc' = 'desc';
|
||||
}
|
||||
4
src/agents/dto/update-agent-profile.dto.ts
Normal file
4
src/agents/dto/update-agent-profile.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateAgentProfileDto } from './create-agent-profile.dto';
|
||||
|
||||
export class UpdateAgentProfileDto extends PartialType(CreateAgentProfileDto) {}
|
||||
Reference in New Issue
Block a user