This is the one that occurs problem.
<input
type="text"
name="nickname"
{...register('nickname', {
required: true,
validate: async (value) =>
value !== profile?.nickname &&
(await validateNickname(value).catch(() => {
return 'Invalid nickname.';
})),
})}
placeholder="Nickname"
/>
- If the input value is not same with the defaultValue
- and It's duplicated with another nickname, (
validateNicknamefunction returns error) Then, error message is registered 'Invalid nickname.'
and the errors object looks like this below.
{
nickname:
message: "Invalid nickname."
ref:...
type: "validate"
}
but the problem is
- If I input the value which is same with the defaultValue,
- or If I input not duplicated value, The errors object should be empty. but it still returns error like this below.
{
nickname:
message: ""
ref:...
type: "validate"
}
so there's no error message registered, but somehow, error is exist.
Please let me know if there's anything I'm doing wrong.
Thanks!