mirror of
https://github.com/strapi/strapi.git
synced 2025-10-12 16:43:39 +00:00
Merge branch 'master' into ctb/improve-stepper
This commit is contained in:
commit
860c2e0789
@ -27,7 +27,9 @@ const RepeatableComponent = ({
|
||||
const [, drop] = useDrop({ accept: ItemTypes.COMPONENT });
|
||||
|
||||
const componentErrorKeys = Object.keys(formErrors)
|
||||
.filter(errorKey => errorKey.includes(name))
|
||||
.filter(errorKey => {
|
||||
return errorKey.split('.')[0] === name;
|
||||
})
|
||||
.map(errorKey => {
|
||||
return errorKey
|
||||
.split('.')
|
||||
@ -123,6 +125,7 @@ const RepeatableComponent = ({
|
||||
onClick={() => {
|
||||
if (componentValueLength < max) {
|
||||
const shouldCheckErrors = hasMinError;
|
||||
|
||||
addRepeatableComponentToField(
|
||||
name,
|
||||
componentUid,
|
||||
|
@ -22,7 +22,6 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
|
||||
try {
|
||||
cleanedData = JSON.parse(value);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
cleanedData = value;
|
||||
}
|
||||
|
||||
|
@ -95,45 +95,26 @@ const createYupSchema = (model, { components }) => {
|
||||
);
|
||||
|
||||
if (attribute.repeatable === true) {
|
||||
const { min, max } = attribute;
|
||||
const { min, max, required } = attribute;
|
||||
let componentSchema = yup.lazy(value => {
|
||||
let baseSchema = yup.array().of(componentFieldSchema);
|
||||
|
||||
let componentSchema =
|
||||
attribute.required === true
|
||||
? yup
|
||||
.array()
|
||||
.of(componentFieldSchema)
|
||||
.defined()
|
||||
: yup
|
||||
.array()
|
||||
.of(componentFieldSchema)
|
||||
.nullable();
|
||||
|
||||
if (min) {
|
||||
componentSchema = yup.lazy(array => {
|
||||
if (attribute.required) {
|
||||
return yup
|
||||
.array()
|
||||
.of(componentFieldSchema)
|
||||
.defined()
|
||||
.min(min, errorsTrads.min);
|
||||
if (min) {
|
||||
if (required) {
|
||||
baseSchema = baseSchema.min(min, errorsTrads.min);
|
||||
} else if (required !== true && isEmpty(value)) {
|
||||
baseSchema = baseSchema.nullable();
|
||||
} else {
|
||||
baseSchema = baseSchema.min(min, errorsTrads.min);
|
||||
}
|
||||
}
|
||||
|
||||
let schema = yup
|
||||
.array()
|
||||
.of(componentFieldSchema)
|
||||
.nullable();
|
||||
if (max) {
|
||||
baseSchema = baseSchema.max(max, errorsTrads.max);
|
||||
}
|
||||
|
||||
if (array && !isEmpty(array)) {
|
||||
schema = schema.min(min, errorsTrads.min);
|
||||
}
|
||||
|
||||
return schema;
|
||||
});
|
||||
}
|
||||
|
||||
if (max) {
|
||||
componentSchema = componentSchema.max(max, errorsTrads.max);
|
||||
}
|
||||
return baseSchema;
|
||||
});
|
||||
|
||||
acc[current] = componentSchema;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user