-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactors librarys and apps using tests
- Loading branch information
Anas Abbal
authored and
Anas Abbal
committed
Jul 11, 2024
1 parent
7cd56d1
commit 9fbb9aa
Showing
74 changed files
with
832 additions
and
2,345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { IsString, IsEmail, MinLength, MaxLength, IsEnum, IsIn } from 'class-validator'; | ||
import { IsEqualTo } from '../util'; | ||
|
||
|
||
|
||
|
||
enum UserType { | ||
DRIVER = 'driver', | ||
RIDER = 'rider', | ||
ADMIN = 'admin', | ||
} | ||
|
||
export class UserCreateCommand { | ||
@IsString() | ||
@MaxLength(50) | ||
firstName: string; | ||
|
||
@IsString() | ||
@MaxLength(50) | ||
lastName: string; | ||
|
||
@IsEmail() | ||
email: string; | ||
|
||
@IsString() | ||
@MinLength(6) | ||
@MaxLength(20) | ||
password: string; | ||
|
||
@IsString() | ||
@MinLength(6) | ||
@MaxLength(20) | ||
@IsEqualTo('password', { message: 'Passwords must match' }) // Use the custom validator | ||
confirmPassword: string; | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { DriverDto } from "@app/shared/events/driver/driver.dto"; | ||
import { Driver } from "typeorm"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { IsString, IsEmail, MinLength, MaxLength, IsEnum, IsIn } from 'class-validator'; | ||
import { IsEqualTo } from '../util'; | ||
|
||
|
||
|
||
|
||
enum UserType { | ||
DRIVER = 'driver', | ||
RIDER = 'rider', | ||
ADMIN = 'admin', | ||
} | ||
|
||
export class UserCreateCommand { | ||
@IsString() | ||
@MaxLength(50) | ||
firstName: string; | ||
|
||
@IsString() | ||
@MaxLength(50) | ||
lastName: string; | ||
|
||
@IsEmail() | ||
email: string; | ||
|
||
@IsString() | ||
@MinLength(6) | ||
@MaxLength(20) | ||
password: string; | ||
|
||
@IsString() | ||
@MinLength(6) | ||
@MaxLength(20) | ||
@IsEqualTo('password', { message: 'Passwords must match' }) // Use the custom validator | ||
confirmPassword: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
export class DriverCreateCmd { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { registerDecorator, ValidationOptions, ValidationArguments } from 'class-validator'; | ||
|
||
|
||
|
||
export function mapDto<T extends Record<string, any>, U extends Record<string, any>>(source: T): U { | ||
const result = {} as U; | ||
|
||
for (const key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
result[key as keyof U] = source[key] as unknown as U[keyof U]; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
||
|
||
export function IsEqualTo(property: string, validationOptions?: ValidationOptions) { | ||
return function (object: Record<string, any>, propertyName: string) { | ||
registerDecorator({ | ||
name: 'isEqualTo', | ||
target: object.constructor, | ||
propertyName: propertyName, | ||
constraints: [property], | ||
options: validationOptions, | ||
validator: { | ||
validate(value: any, args: ValidationArguments) { | ||
const [relatedPropertyName] = args.constraints; | ||
const relatedValue = (args.object as any)[relatedPropertyName]; | ||
return value === relatedValue; | ||
}, | ||
}, | ||
}); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.