mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
Fix some bugs (User edit & CM validations) (#11653)
Signed-off-by: HichamELBSI <elabbassih@gmail.com>
This commit is contained in:
parent
2c6ece8c5e
commit
6e86b526f1
@ -518,7 +518,9 @@ const EditViewDataManagerProvider = ({
|
||||
when={!isEqual(modifiedData, initialData)}
|
||||
message={formatMessage({ id: 'global.prompt.unsaved' })}
|
||||
/>
|
||||
<form onSubmit={handleSubmit}>{children}</form>
|
||||
<form noValidate onSubmit={handleSubmit}>
|
||||
{children}
|
||||
</form>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
@ -300,7 +300,7 @@ const createYupSchemaAttribute = (type, validations, options) => {
|
||||
return !isEmpty(value);
|
||||
}
|
||||
|
||||
return !isEmpty(value.toString());
|
||||
return !isEmpty(value?.toString());
|
||||
}
|
||||
|
||||
return !isEmpty(value);
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as yup from 'yup';
|
||||
import profileValidation from './profile';
|
||||
import { commonUserSchema } from './profile';
|
||||
import rolesValidation from './roles';
|
||||
|
||||
const schema = yup.object().shape({
|
||||
...profileValidation,
|
||||
...commonUserSchema,
|
||||
isActive: yup.bool(),
|
||||
...rolesValidation,
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
|
||||
const schema = {
|
||||
export const commonUserSchema = {
|
||||
firstname: yup.mixed().required(translatedErrors.required),
|
||||
lastname: yup.mixed().required(translatedErrors.required),
|
||||
email: yup
|
||||
@ -23,6 +23,10 @@ const schema = {
|
||||
.when('password', (password, passSchema) => {
|
||||
return password ? passSchema.required(translatedErrors.required) : passSchema;
|
||||
}),
|
||||
};
|
||||
|
||||
const schema = {
|
||||
...commonUserSchema,
|
||||
currentPassword: yup
|
||||
.string()
|
||||
.when(['password', 'confirmPassword'], (password, confirmPassword, passSchema) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user