[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:
+11
@@ -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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user