mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-10-25 21:47:56 +00:00
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { IsDateString, IsEmail, IsNotEmpty, IsString, Matches } from 'class-validator';
|
|
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
|
import { COUNTRY_CODE_REGEX } from '~/auth/constants';
|
|
import { IsValidPhoneNumber } from '~/core/decorators/validations';
|
|
|
|
export class CreateJuniorUserRequestDto {
|
|
@ApiProperty({ example: '+962' })
|
|
@Matches(COUNTRY_CODE_REGEX, {
|
|
message: i18n('validation.Matches', { path: 'general', property: 'auth.countryCode' }),
|
|
})
|
|
countryCode: string = '+966';
|
|
|
|
@ApiProperty({ example: '787259134' })
|
|
@IsValidPhoneNumber({
|
|
message: i18n('validation.IsValidPhoneNumber', { path: 'general', property: 'auth.phoneNumber' }),
|
|
})
|
|
phoneNumber!: string;
|
|
|
|
@ApiProperty({ example: 'John' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.firstName' }) })
|
|
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'auth.firstName' }) })
|
|
firstName!: string;
|
|
|
|
@ApiProperty({ example: 'Doe' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.lastName' }) })
|
|
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'auth.lastName' }) })
|
|
lastName!: string;
|
|
|
|
@ApiProperty({ example: '2020-01-01' })
|
|
@IsDateString({}, { message: i18n('validation.IsDateString', { path: 'general', property: 'customer.dateOfBirth' }) })
|
|
dateOfBirth!: Date;
|
|
|
|
@ApiProperty({ example: '[email protected]' })
|
|
@IsEmail({}, { message: i18n('validation.IsEmail', { path: 'general', property: 'auth.email' }) })
|
|
email!: string;
|
|
}
|