Common - Field validation (#15491)

Closes : https://github.com/twentyhq/core-team-issues/issues/1622

To do in other PR : 
- Add migration command for non nullable text, raw_json & array fields
- Add null transformation

---------

Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
Etienne
2025-11-13 15:45:35 +01:00
committed by GitHub
co-authored by Weiko
parent f6ed1e8295
commit 261cba40ef
114 changed files with 3524 additions and 1189 deletions
@@ -32,9 +32,9 @@ describe('computeSchemaComponents', () => {
"lastName": "Osinski",
},
"fieldLinks": {
"additionalLinks": [],
"primaryLinkLabel": "",
"primaryLinkUrl": "https://narrow-help.net/",
"secondaryLinks": [],
},
"fieldMultiSelect": [
"OPTION_1",
@@ -46,9 +46,7 @@ describe('computeSchemaComponents', () => {
"primaryPhoneCountryCode": "FR",
"primaryPhoneNumber": "06 10 20 30 40",
},
"fieldSelect": [
"OPTION_1",
],
"fieldSelect": "OPTION_1",
},
"properties": {
"fieldActor": {
@@ -535,9 +533,9 @@ describe('computeSchemaComponents', () => {
"lastName": "Jones",
},
"fieldLinks": {
"additionalLinks": [],
"primaryLinkLabel": "",
"primaryLinkUrl": "https://unlawful-blowgun.biz",
"secondaryLinks": [],
},
"fieldMultiSelect": [
"OPTION_1",
@@ -549,9 +547,7 @@ describe('computeSchemaComponents', () => {
"primaryPhoneCountryCode": "FR",
"primaryPhoneNumber": "06 10 20 30 40",
},
"fieldSelect": [
"OPTION_1",
],
"fieldSelect": "OPTION_1",
},
"properties": {
"fieldActor": {
@@ -58,7 +58,7 @@ export const generateRandomFieldValue = ({
return {
primaryLinkLabel: '',
primaryLinkUrl: faker.internet.url(),
additionalLinks: [],
secondaryLinks: [],
};
}
@@ -82,10 +82,10 @@ export const generateRandomFieldValue = ({
case FieldMetadataType.SELECT: {
if (!isDefined(field.options) || !isDefined(field.options[0].value)) {
return [];
return null;
}
return [field.options[0].value];
return field.options[0].value;
}
case FieldMetadataType.MULTI_SELECT: {