mirror of
https://github.com/strapi/strapi.git
synced 2025-08-18 13:45:25 +00:00
Merge pull request #4771 from strapi/ctm/fix-components
Fix edit component with min value when not required
This commit is contained in:
commit
d6a00ccffd
@ -52,6 +52,7 @@ const RepeatableComponent = ({
|
||||
const errorsArray = componentErrorKeys.map(key =>
|
||||
get(formErrors, [key, 'id'], '')
|
||||
);
|
||||
|
||||
const hasMinError =
|
||||
get(errorsArray, [0], '').includes('min') &&
|
||||
!collapses.some(obj => obj.isOpen === true);
|
||||
|
@ -266,7 +266,7 @@ const EditViewDataManagerProvider = ({
|
||||
});
|
||||
redirectToPreviousPage();
|
||||
} catch (err) {
|
||||
console.log({ err });
|
||||
console.error({ err });
|
||||
const error = get(
|
||||
err,
|
||||
['response', 'payload', 'message', '0', 'messages', '0', 'id'],
|
||||
@ -281,6 +281,7 @@ const EditViewDataManagerProvider = ({
|
||||
}
|
||||
} catch (err) {
|
||||
const errors = getYupInnerErrors(err);
|
||||
console.error({ err, errors });
|
||||
|
||||
dispatch({
|
||||
type: 'SUBMIT_ERRORS',
|
||||
|
@ -109,7 +109,26 @@ const createYupSchema = (model, { components }) => {
|
||||
.nullable();
|
||||
|
||||
if (min) {
|
||||
componentSchema = componentSchema.min(min, errorsTrads.min);
|
||||
componentSchema = yup.lazy(array => {
|
||||
if (attribute.required) {
|
||||
return yup
|
||||
.array()
|
||||
.of(componentFieldSchema)
|
||||
.defined()
|
||||
.min(min, errorsTrads.min);
|
||||
}
|
||||
|
||||
let schema = yup
|
||||
.array()
|
||||
.of(componentFieldSchema)
|
||||
.nullable();
|
||||
|
||||
if (array && !isEmpty(array)) {
|
||||
schema = schema.min(min, errorsTrads.min);
|
||||
}
|
||||
|
||||
return schema;
|
||||
});
|
||||
}
|
||||
|
||||
if (max) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user