Skip to content

Commit

Permalink
trim email
Browse files Browse the repository at this point in the history
trim input

update trim
  • Loading branch information
nguyenhoaidanh committed Sep 18, 2023
1 parent 0e06f7f commit 6aca6aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const useValidateEmail = (defaultEmail?: string) => {
[defaultEmail],
)

return { inputEmail, onChangeEmail, errorInput, errorColor, hasErrorInput, reset }
return { inputEmail: inputEmail.trim(), onChangeEmail, errorInput, errorColor, hasErrorInput, reset }
}

function NotificationPreference({
Expand Down
3 changes: 2 additions & 1 deletion src/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const escapeScriptHtml = (str: string) => {
return str.replace(/<.*?script.*?>.*?<\/.*?script.*?>/gim, '')
}

export const isEmailValid = (value: string | undefined) => value?.match(/^\w+([\.-]?\w)*@\w+([\.-]?\w)*(\.\w{2,10})+$/)
export const isEmailValid = (value: string | undefined) =>
(value || '').trim().match(/^\w+([\.-]?\w)*@\w+([\.-]?\w)*(\.\w{2,10})+$/)

export const getChainIdFromSlug = (network: string | undefined): ChainId | undefined => {
return SUPPORTED_NETWORKS.find(chainId => NETWORKS_INFO[chainId].route === network)
Expand Down

0 comments on commit 6aca6aa

Please sign in to comment.