Skip to content

Commit c62289b

Browse files
sblivenJunjiequan
authored andcommitted
Fix error
1 parent 9c60378 commit c62289b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/users/dto/create-user.dto.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ export function isCreateUserDto(obj: unknown): obj is CreateUserDto {
3838
// Check for extra fields
3939
const objKeys = Object.keys(obj);
4040
if (!objKeys.every((key) => allowedKeys.includes(key))) return false;
41-
if (!allowedKeys.slice(0, 2).every((key) => objKeys.includes(key)))
42-
return false; // username & email required
4341

4442
// Type checks
45-
if (typeof obj.username !== "string") return false;
46-
if (typeof obj.email !== "string") return false;
43+
if (!("username" in obj) || typeof obj.username !== "string") return false;
44+
if (!("email" in obj) || typeof obj.email !== "string") return false;
4745
if ("password" in obj && typeof obj.password !== "string") return false;
4846
if ("role" in obj && typeof obj.role !== "string") return false;
4947
if ("global" in obj && typeof obj.global !== "boolean") return false;

0 commit comments

Comments
 (0)