From 88d67c7b0bcd194bec7cf6995af5b92571c92f25 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Sat, 26 Aug 2023 16:27:29 -0700 Subject: [PATCH 1/3] Remove required. --- src/pages/api/users/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/api/users/index.ts b/src/pages/api/users/index.ts index 0b523c70..fd1585d4 100644 --- a/src/pages/api/users/index.ts +++ b/src/pages/api/users/index.ts @@ -25,10 +25,7 @@ const schema = { username: yup.string().max(255).required(), password: yup.string().required(), id: yup.string().uuid(), - role: yup - .string() - .matches(/admin|user|view-only/i) - .required(), + role: yup.string().matches(/admin|user|view-only/i), }), }; From fcd7fac2ce635a5e757bcb9e419531663ca599b5 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Sat, 26 Aug 2023 16:33:22 -0700 Subject: [PATCH 2/3] Re-add required. --- src/pages/api/users/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/api/users/index.ts b/src/pages/api/users/index.ts index fd1585d4..0b523c70 100644 --- a/src/pages/api/users/index.ts +++ b/src/pages/api/users/index.ts @@ -25,7 +25,10 @@ const schema = { username: yup.string().max(255).required(), password: yup.string().required(), id: yup.string().uuid(), - role: yup.string().matches(/admin|user|view-only/i), + role: yup + .string() + .matches(/admin|user|view-only/i) + .required(), }), }; From f2f55170513d9a9735a058a2a800621eb3eab6b8 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Sat, 26 Aug 2023 16:35:43 -0700 Subject: [PATCH 3/3] fix type. --- src/pages/api/users/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/users/index.ts b/src/pages/api/users/index.ts index 0b523c70..991986e8 100644 --- a/src/pages/api/users/index.ts +++ b/src/pages/api/users/index.ts @@ -13,7 +13,7 @@ export interface UsersRequestBody { username: string; password: string; id: string; - role?: Role; + role: Role; } import * as yup from 'yup';