mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 13:00:13 +02:00
Add initial users manager
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { z } from 'zod';
|
||||
import { idValidation } from './shared.validation';
|
||||
|
||||
const noWhiteSpaces = /^\S*$/;
|
||||
|
||||
const list = {
|
||||
body: z.object({}),
|
||||
params: z.object({}),
|
||||
query: z.object({}),
|
||||
};
|
||||
|
||||
const detail = {
|
||||
body: z.object({}),
|
||||
params: z.object({ ...idValidation('userId') }),
|
||||
@@ -9,9 +17,16 @@ const detail = {
|
||||
|
||||
const createUser = {
|
||||
body: z.object({
|
||||
displayName: z.optional(z.string()),
|
||||
displayName: z.optional(z.string().min(0).max(100)),
|
||||
isAdmin: z.optional(z.boolean()),
|
||||
password: z.string().min(6).max(255),
|
||||
username: z.string().min(2).max(255),
|
||||
username: z
|
||||
.string()
|
||||
.min(2)
|
||||
.max(30)
|
||||
.refine((value) => noWhiteSpaces.test(value), {
|
||||
message: 'No white spaces allowed',
|
||||
}),
|
||||
}),
|
||||
params: z.object({}),
|
||||
query: z.object({}),
|
||||
@@ -25,9 +40,18 @@ const deleteUser = {
|
||||
|
||||
const updateUser = {
|
||||
body: z.object({
|
||||
displayName: z.optional(z.string().min(2).max(255)),
|
||||
displayName: z.optional(z.string().min(0).max(100)),
|
||||
isAdmin: z.optional(z.boolean()),
|
||||
password: z.optional(z.string().min(6).max(255)),
|
||||
username: z.optional(z.string().min(2).max(255)),
|
||||
username: z.optional(
|
||||
z
|
||||
.string()
|
||||
.min(2)
|
||||
.max(30)
|
||||
.refine((value) => noWhiteSpaces.test(value), {
|
||||
message: 'No white spaces allowed',
|
||||
})
|
||||
),
|
||||
}),
|
||||
params: z.object({ ...idValidation('userId') }),
|
||||
query: z.object({}),
|
||||
@@ -37,5 +61,6 @@ export const usersValidation = {
|
||||
createUser,
|
||||
deleteUser,
|
||||
detail,
|
||||
list,
|
||||
updateUser,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user