improvement: appointment dialog UX improved.
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsDateString, IsEmail, IsOptional, IsString, MaxLength, MinLength } from 'class-validator';
|
||||
import { ErrorCode } from '../../../common/errors';
|
||||
|
||||
function emptyStringToUndefined({ value }: { value: unknown }): unknown {
|
||||
if (typeof value === 'string' && value.trim() === '') {
|
||||
return undefined;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export class CreatePatientDto {
|
||||
@IsString()
|
||||
@MinLength(1, { message: ErrorCode.VALIDATION_FIELD_REQUIRED })
|
||||
@@ -18,6 +26,7 @@ export class CreatePatientDto {
|
||||
mobile: string;
|
||||
|
||||
@IsOptional()
|
||||
@Transform(emptyStringToUndefined)
|
||||
@IsEmail({}, { message: ErrorCode.VALIDATION_EMAIL_INVALID })
|
||||
email?: string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user