From c1b760ca9e1c977396fa0fd201c7b09ab0b0ba39 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 3 Jun 2024 12:43:51 +0200 Subject: [PATCH] Validate that required fields can't be hidden in views --- packages/server/src/sdk/app/views/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index ff51a73e99..98871539c2 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -74,7 +74,15 @@ async function guardViewSchema( } const viewSchemaField = viewSchema[field.name] - if (viewSchemaField?.readonly) { + + if (!viewSchemaField?.visible) { + throw new HTTPError( + `You can't hide the required field "${field.name}"`, + 400 + ) + } + + if (viewSchemaField.readonly) { throw new HTTPError( `You can't make read only the required field "${field.name}"`, 400