Skip to content

Commit 64a7089

Browse files
author
hirsch88
committed
improve request body
1 parent f2d72b2 commit 64a7089

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/api/requests/UserUpdateRequest.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,23 @@ import { RequestBody } from '../../core/api/RequestBody';
1212
*/
1313
export class UserUpdateRequest extends RequestBody {
1414

15-
@IsNotEmpty()
16-
id: number;
17-
1815
@IsNotEmpty()
1916
firstName: string;
2017

2118
@IsNotEmpty()
2219
lastName: string;
2320

24-
@IsNotEmpty()
2521
@IsEmail()
2622
email: string;
2723

24+
@IsNotEmpty()
2825
picture: string;
2926

27+
@IsNotEmpty()
3028
auth0UserId: string;
3129

32-
setFirstName(value: string): void {
33-
this.update('firstName', value);
34-
}
35-
36-
setLastName(value: string): void {
37-
this.update('lastName', value);
38-
}
39-
40-
setEmail(value: string): void {
41-
this.update('email', value);
30+
public async validate(): Promise<void> {
31+
return super.validate(true);
4232
}
4333

4434
}

src/core/api/RequestBody.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class RequestBody {
2828
/**
2929
* Validates the body on the basis of the validator-annotations
3030
*/
31-
public async validate(): Promise<void> {
32-
const errors = await validate(this);
31+
public async validate(skipMissingProperties: boolean = false): Promise<void> {
32+
const errors = await validate(this, { skipMissingProperties: skipMissingProperties });
3333
if (errors && errors.length > 0) {
3434
throw new ValidationException('Request body is not valid', errors);
3535
}

0 commit comments

Comments
 (0)