From c177b5b9b42fbfcbb9bc1e5e926de92cc63f48ec Mon Sep 17 00:00:00 2001 From: Rayan Salhab Date: Fri, 27 Mar 2026 01:11:24 +0000 Subject: [PATCH] fix(core): allow null/undefined values for required fields with defaults When a field is required (notNull) but has a default value defined, null or undefined inputs should be allowed to pass through validation since the default value will be applied later in the record creation process. Fixes #2771 --- packages/core/src/models/field/field.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/core/src/models/field/field.ts b/packages/core/src/models/field/field.ts index 781dd86a0d..e29bf8747e 100644 --- a/packages/core/src/models/field/field.ts +++ b/packages/core/src/models/field/field.ts @@ -98,12 +98,20 @@ export abstract class FieldCore implements IFieldVo { /** * Wrapper to enforce notNull when calling validateCellValue. + * If the field has a default value, null/undefined inputs are allowed + * since the default will be applied later. */ validateCellValueWithNotNull(value: unknown): ZodSafeParseResult | undefined { if (this.isComputed) { return this.validateCellValue(value); } if (this.notNull && (value === null || value === undefined)) { + // Check if field has a default value - if so, allow null/undefined + // since the default will be applied later + const options = this.options as { defaultValue?: unknown } | undefined; + if (options?.defaultValue !== undefined) { + return this.validateCellValue(value); + } return { success: false, error: new ZodError([