fix(content-manager): allow required on relations on schema but ignore it

This commit is contained in:
Fernando Chavez 2024-06-19 18:30:38 +02:00
parent 7b4ac52a49
commit 06f526742a
2 changed files with 1 additions and 8 deletions

View File

@ -216,7 +216,7 @@ type ValidationFn = (
) => <TSchema extends AnySchema>(schema: TSchema) => TSchema;
const addRequiredValidation: ValidationFn = (attribute) => (schema) => {
if (attribute.required) {
if (attribute.required && attribute.type !== 'relation') {
return schema.required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required.',

View File

@ -158,13 +158,6 @@ 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;
}