mirror of
https://github.com/strapi/strapi.git
synced 2025-09-08 08:08:18 +00:00
fix(content-manager): allow required on relations on schema but ignore it
This commit is contained in:
parent
7b4ac52a49
commit
06f526742a
@ -216,7 +216,7 @@ type ValidationFn = (
|
|||||||
) => <TSchema extends AnySchema>(schema: TSchema) => TSchema;
|
) => <TSchema extends AnySchema>(schema: TSchema) => TSchema;
|
||||||
|
|
||||||
const addRequiredValidation: ValidationFn = (attribute) => (schema) => {
|
const addRequiredValidation: ValidationFn = (attribute) => (schema) => {
|
||||||
if (attribute.required) {
|
if (attribute.required && attribute.type !== 'relation') {
|
||||||
return schema.required({
|
return schema.required({
|
||||||
id: translatedErrors.required.id,
|
id: translatedErrors.required.id,
|
||||||
defaultMessage: 'This field is required.',
|
defaultMessage: 'This field is required.',
|
||||||
|
@ -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: {
|
default: {
|
||||||
return attribute;
|
return attribute;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user