mirror of
https://github.com/strapi/strapi.git
synced 2025-08-24 00:27:13 +00:00
Fix oneWay, manyWay relation validations
This commit is contained in:
parent
948b49a8b0
commit
c77da616f2
@ -206,11 +206,16 @@ const forms = {
|
||||
.matches(NAME_REGEX, errorsTrads.regex)
|
||||
.unique(errorsTrads.unique, alreadyTakenAttributes)
|
||||
.required(errorsTrads.required),
|
||||
targetAttribute: yup
|
||||
.string()
|
||||
.matches(NAME_REGEX, errorsTrads.regex)
|
||||
targetAttribute: yup.lazy(() => {
|
||||
let schema = yup.string();
|
||||
|
||||
if (!['oneWay', 'manyWay'].includes(dataToValidate.nature)) {
|
||||
schema = schema.matches(NAME_REGEX, errorsTrads.regex);
|
||||
}
|
||||
return schema
|
||||
.unique(errorsTrads.unique, targetAttributeAlreadyTakenValue)
|
||||
.required(errorsTrads.required),
|
||||
.required(errorsTrads.required);
|
||||
}),
|
||||
target: yup.string().required(errorsTrads.required),
|
||||
nature: yup.string().required(),
|
||||
dominant: yup.boolean().nullable(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user