From cd1a7699b23f3471dae4a848b58ecd80611298d5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 2 Aug 2024 13:12:47 +0200 Subject: [PATCH] Fix schema require checks --- packages/server/src/utilities/schema.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utilities/schema.ts b/packages/server/src/utilities/schema.ts index 16082dbcb7..2613190b9c 100644 --- a/packages/server/src/utilities/schema.ts +++ b/packages/server/src/utilities/schema.ts @@ -84,7 +84,7 @@ export function validate( "Column names can't contain special characters" } else if ( columnData == null && - !schema[columnName].constraints?.presence + !helpers.schema.isRequired(constraints) ) { results.schemaValidation[columnName] = true } else if ( @@ -94,6 +94,11 @@ export function validate( isAutoColumn ) { return + } else if ( + [FieldType.STRING].includes(columnType) && + helpers.schema.isRequired(constraints) + ) { + results.schemaValidation[columnName] = false } else if (columnType === FieldType.NUMBER && isNaN(Number(columnData))) { // If provided must be a valid number results.schemaValidation[columnName] = false