-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(players): cleanup PlayersController (#2757)
- Loading branch information
1 parent
89c5393
commit 7ccda21
Showing
7 changed files
with
66 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Types } from 'mongoose'; | ||
import { z } from 'zod'; | ||
import { PlayerId } from '../types/player-id'; | ||
|
||
export const addPlayerBanSchema = z.object({ | ||
player: z | ||
.string() | ||
.refine((val) => Types.ObjectId.isValid(val), { | ||
message: 'player has to be a valid player id', | ||
}) | ||
.transform((val) => new Types.ObjectId(val) as PlayerId), | ||
admin: z | ||
.string() | ||
.refine((val) => Types.ObjectId.isValid(val), { | ||
message: 'admin has to be a valid player id', | ||
}) | ||
.transform((val) => new Types.ObjectId(val) as PlayerId), | ||
start: z | ||
.string() | ||
.datetime() | ||
.transform((val) => new Date(val)), | ||
end: z | ||
.string() | ||
.datetime() | ||
.transform((val) => new Date(val)), | ||
reason: z.string().optional(), | ||
}); |
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,6 @@ | ||
import { z } from 'zod'; | ||
|
||
export const forceCreatePlayerSchema = z.object({ | ||
name: z.string(), | ||
steamId: z.string().regex(/^\d{17}$/), | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { z } from 'zod'; | ||
import { PlayerRole } from '../models/player-role'; | ||
|
||
export const updatePlayerSchema = z.object({ | ||
name: z.string().optional(), | ||
avatar: z | ||
.object({ | ||
small: z.string(), | ||
medium: z.string(), | ||
large: z.string(), | ||
}) | ||
.optional(), | ||
roles: z.array(z.nativeEnum(PlayerRole)).optional(), | ||
}); |