[Fix] Forbid default value removal for non-nullable select field (#16465)

Permanently fixes https://github.com/twentyhq/private-issues/issues/389

On a non-nullable select field, default value should not be removable,
otherwise users won't be able to create new records from the interface.
This PR enforces this in FE and BE.


https://github.com/user-attachments/assets/1dfa2bcc-b9df-4a00-9915-679d36ec1b25
This commit is contained in:
Marie
2025-12-11 00:53:48 +01:00
committed by GitHub
parent bed5270f3c
commit 7a7f36d38c
3 changed files with 62 additions and 35 deletions
@@ -158,6 +158,17 @@ export class FlatFieldMetadataValidatorService {
});
}
if (
flatFieldMetadataToValidate.isNullable === false &&
flatFieldMetadataToValidate.defaultValue === null
) {
validationResult.errors.push({
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
message: 'Default value cannot be null for non-nullable fields',
userFriendlyMessage: msg`Default value cannot be null.`,
});
}
const fieldMetadataTypeValidationErrors =
this.flatFieldMetadataTypeValidatorService.validateFlatFieldMetadataTypeSpecificities(
{