Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/core/src/models/field/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown> | 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([
Expand Down