You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue arises when utilizing the validateEmail prop with a custom validation in react-multi-email. The library returns the email only if it passes its internal validation, thereby overwriting the custom validation. This occurs within the initialEmailAddress function, which executes within a useEffect with the emails array as a dependency. Consequently, each time a user adds emails, the function fires and overrides the custom validation. The culprit is in the filter function applied to the emails array, which forces validation via isEmailFn, thus disregarding the custom validation.
Currently, I have temporarily copied the library files to my project with the fix implemented. Once the PR is merged, I will revert to using the library directly.
The text was updated successfully, but these errors were encountered:
Description
The issue arises when utilizing the
validateEmail
prop with a custom validation inreact-multi-email
. The library returns the email only if it passes its internal validation, thereby overwriting the custom validation. This occurs within theinitialEmailAddress
function, which executes within auseEffect
with theemails
array as a dependency. Consequently, each time a user adds emails, the function fires and overrides the custom validation. The culprit is in the filter function applied to theemails
array, which forces validation viaisEmailFn
, thus disregarding the custom validation.Fix suggestion
Move
initialEmailAddress
function inside the component. right under the useStates.And change the function to look like this:
Steps to Reproduce
validateEmail
prop with a custom validation.Expected Behavior
The component should respect the user's intention to employ a custom validation.
Actual Behavior
The component fails to respect the custom validation and instead prioritizes the library's isEmail validation.
Additional Notes
The text was updated successfully, but these errors were encountered: