mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
25 lines
1022 B
TypeScript
25 lines
1022 B
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString, Matches, ValidateIf } from 'class-validator';
|
|
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
|
import { COUNTRY_CODE_REGEX } from '~/auth/constants';
|
|
import { GrantType } from '~/auth/enums';
|
|
import { IsValidPhoneNumber } from '~/core/decorators/validations';
|
|
export class LoginRequestDto {
|
|
@ApiProperty({ example: '+962' })
|
|
@Matches(COUNTRY_CODE_REGEX, {
|
|
message: i18n('validation.Matches', { path: 'general', property: 'auth.countryCode' }),
|
|
})
|
|
countryCode!: string;
|
|
|
|
@ApiProperty({ example: '787259134' })
|
|
@IsValidPhoneNumber({
|
|
message: i18n('validation.IsValidPhoneNumber', { path: 'general', property: 'auth.phoneNumber' }),
|
|
})
|
|
phoneNumber!: string;
|
|
|
|
@ApiProperty({ example: 'Abcd1234@' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.password' }) })
|
|
@ValidateIf((o) => o.grantType === GrantType.PASSWORD)
|
|
password!: string;
|
|
}
|