Morph relation validation v2 (#14141)

## Introduction
Binding morph relation validation to relation validation code flow
Please note that ALL create field will go through basic atomic
validation, which involve name availability and so on

close https://github.com/twentyhq/core-team-issues/issues/1407
This commit is contained in:
Paul Rastoin
2025-08-28 18:05:58 +02:00
committed by GitHub
parent af6fc1e9ef
commit b364acf5bb
6 changed files with 91 additions and 70 deletions
@@ -4,8 +4,8 @@ exports[`fromCreateFieldInputToFlatFieldMetadatasToCreate MORPH_RELATION test su
{
"error": {
"code": "FIELD_METADATA_RELATION_MALFORMED",
"message": "Morph relation relations must have the same relation type",
"userFriendlyMessage": "Morph relation relations must have the same relation type",
"message": "Morph relation creation payloads must have the same relation type",
"userFriendlyMessage": "Morph relation creation payloads must have the same relation type",
},
"status": "fail",
}
@@ -32,8 +32,8 @@ exports[`fromCreateFieldInputToFlatFieldMetadatasToCreate MORPH_RELATION test su
{
"error": {
"code": "FIELD_METADATA_RELATION_MALFORMED",
"message": "Morph relation relations must have only relation to the same object metadata",
"userFriendlyMessage": "Morph relation relations must have only relation to the same object metadata",
"message": "Morph relation creation payloads must have only relation to the same object metadata",
"userFriendlyMessage": "Morph relation creation payloads must only contain relation to the same object metadata",
},
"status": "fail",
}
@@ -42,10 +42,9 @@ exports[`fromCreateFieldInputToFlatFieldMetadatasToCreate MORPH_RELATION test su
exports[`fromCreateFieldInputToFlatFieldMetadatasToCreate MORPH_RELATION test suite Failure cases should fail when morphRelationsCreationPayload is empty array 1`] = `
{
"error": {
"code": "INVALID_FIELD_INPUT",
"message": "Relation creation payload is required",
"userFriendlyMessage": "Relation creation payload is required",
"value": [],
"code": "FIELD_METADATA_RELATION_MALFORMED",
"message": "Morph relation creation payloads are empty",
"userFriendlyMessage": "At least one relation is require",
},
"status": "fail",
}