mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Fix validation on user update
This commit is contained in:
parent
33debd5701
commit
3ef2eabdad
@ -18,7 +18,7 @@ const createUserBodySchema = yup.object().shape({
|
||||
connect: yup
|
||||
.array()
|
||||
.of(yup.object().shape({ id: yup.strapiID().required() }))
|
||||
.min(1)
|
||||
.min(1, 'Users must have a role')
|
||||
.required(),
|
||||
})
|
||||
.required()
|
||||
@ -36,7 +36,16 @@ const updateUserBodySchema = yup.object().shape({
|
||||
connect: yup
|
||||
.array()
|
||||
.of(yup.object().shape({ id: yup.strapiID().required() }))
|
||||
.min(1)
|
||||
.required(),
|
||||
disconnect: yup
|
||||
.array()
|
||||
.test('CheckDisconnect', 'Cannot remove role', function test(disconnectValue) {
|
||||
if (value.connect.length === 0 && disconnectValue.length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.required(),
|
||||
})
|
||||
: yup.strapiID()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user