mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 04:15:43 +00:00
- Replaced PhoneInput component with ControlledPhoneField for better integration with react-hook-form. - Updated validation for phone numbers using isValidPhone function to ensure proper formatting. - Removed country code handling from forms, simplifying phone number management. - Introduced new phone field component with consistent styling and behavior. - Added phone number validation on the backend using class-validator. - Removed unused phone utility functions and cleaned up related code.
80 lines
1.5 KiB
TypeScript
80 lines
1.5 KiB
TypeScript
import { IsString, IsNotEmpty, IsOptional, IsEmail, MaxLength, IsBoolean, IsEnum, IsArray, ValidateNested, ArrayMinSize } from 'class-validator';
|
|
import { Type } from 'class-transformer';
|
|
import { CompanyType } from '../entities/company.entity';
|
|
import { ProfileType } from '../entities/company-profile.entity';
|
|
import { IsValidPhone } from '../../../common/validators/is-phone-number.validator';
|
|
|
|
export class CompanyProfileInputDto {
|
|
@IsEnum(ProfileType)
|
|
type!: ProfileType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(100)
|
|
businessLicense?: string;
|
|
}
|
|
|
|
export class CreateCompanyWithProfileDto {
|
|
@IsEnum(CompanyType)
|
|
companyType!: CompanyType;
|
|
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(200)
|
|
companyName!: string;
|
|
|
|
@IsOptional()
|
|
@IsEmail()
|
|
@MaxLength(150)
|
|
companyEmail?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(20)
|
|
@IsValidPhone()
|
|
companyPhone?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(32)
|
|
companyLocation?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
companyAddress?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(10)
|
|
tin?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(50)
|
|
vatNumber?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(16)
|
|
fanNumber?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(100)
|
|
jobTitle?: string;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isPrimaryContact?: boolean;
|
|
|
|
@IsOptional()
|
|
attributes?: Record<string, any>;
|
|
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ArrayMinSize(1)
|
|
@ValidateNested({ each: true })
|
|
@Type(() => CompanyProfileInputDto)
|
|
companyProfiles?: CompanyProfileInputDto[];
|
|
}
|