fix(core): disallow required on relation fields on schemas

This commit is contained in:
Fernando Chavez 2024-06-19 11:32:59 +02:00
parent cefa185d29
commit 7b4ac52a49
2 changed files with 7 additions and 5 deletions

View File

@ -216,11 +216,6 @@ const createRelationValidator =
validator = yup.mixed();
}
validator = addRequiredValidation(createOrUpdate)(validator, {
attr: { required: !isDraft && attr.required },
updatedAttribute,
});
return validator;
};

View File

@ -158,6 +158,13 @@ export const transformAttribute = (
},
};
}
case 'relation': {
if (attribute.required) {
throw new Error(
`Required relations are not supported, please remove it from ${contentType.collectionName} schema on the attribute ${name}`
);
}
}
default: {
return attribute;
}