fix(profile-form): optional email
This commit is contained in:
parent
ccd8373edb
commit
426054bc0e
1 changed files with 6 additions and 14 deletions
|
@ -35,19 +35,11 @@ const schema = {
|
||||||
properties: {
|
properties: {
|
||||||
login: { type: "string" },
|
login: { type: "string" },
|
||||||
email: {
|
email: {
|
||||||
oneOf: [
|
type: "string",
|
||||||
{
|
pattern: "^$|^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", // format: "email" doesn't seem to allow optional (tried many approaches)
|
||||||
type: "string",
|
errorMessage: {
|
||||||
format: "email",
|
pattern: "adresse email invalide",
|
||||||
errorMessage: {
|
},
|
||||||
format: "adresse email invalide",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "string",
|
|
||||||
maxLength: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -101,7 +93,7 @@ export default function Form({
|
||||||
|
|
||||||
const onSubmit = useCallback(
|
const onSubmit = useCallback(
|
||||||
async (data) => {
|
async (data) => {
|
||||||
if (!(email && email === data.email)) {
|
if (data.email && !(email && email === data.email)) {
|
||||||
const isRegistered = await checkEmailIsRegistered(data.email);
|
const isRegistered = await checkEmailIsRegistered(data.email);
|
||||||
if (isRegistered) {
|
if (isRegistered) {
|
||||||
setError("email", {
|
setError("email", {
|
||||||
|
|
Loading…
Add table
Reference in a new issue