feat: add simple login logic
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import Utils from '@/common/utils';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsNotEmpty, IsOptional, IsString, Matches } from 'class-validator';
|
||||
import { i18nValidationMessage as t } from 'nestjs-i18n';
|
||||
|
||||
export class LoginDTO {
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
description: `User's Phone Number`,
|
||||
example: '09121111111',
|
||||
required: true,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty({
|
||||
message: t('validation.requiredField', {
|
||||
field: '$t(auth.fields.phone)',
|
||||
}),
|
||||
})
|
||||
@Matches(/^(?:09|9)[0-9]{9}$/, {
|
||||
message: t('validation.wrongField', {
|
||||
field: '$t(auth.fields.phone)',
|
||||
}),
|
||||
})
|
||||
@Transform(({ value }) => Utils.StringUtils.normalizePhone(value as string))
|
||||
phone: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
description: 'Password for User Account',
|
||||
example: 'Password1@',
|
||||
required: false,
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString({
|
||||
message: t('validation.wrongFieldFormat', {
|
||||
field: '$t(auth.fields.password)',
|
||||
}),
|
||||
})
|
||||
password?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user