Skip to content

Commit

Permalink
Merge pull request #17254 from dukenv0307/fix/16884-no-error-message-…
Browse files Browse the repository at this point in the history
…when-entering-a-invalid-email

Fix: No error message when entering a invalid email
  • Loading branch information
neil-marcellini authored Apr 17, 2023
2 parents bf1167b + 65ac54f commit c994994
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ export default {
},
messages: {
errorMessageInvalidPhone: `Please enter a valid phone number without brackets or dashes. If you're outside the US please include your country code (e.g. ${CONST.EXAMPLE_PHONE_NUMBER}).`,
errorMessageInvalidEmail: 'Invalid email',
},
onfidoStep: {
acceptTerms: 'By continuing with the request to activate your Expensify wallet, you confirm that you have read, understand and accept ',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ export default {
},
},
messages: {
errorMessageInvalidPhone: `Por favor, introduce un número de teléfono válido sin paréntesis o guiones. Si reside fuera de Estados Unidos, incluye el prefijo internacional (p. ej. ${CONST.EXAMPLE_PHONE_NUMBER}).`,
errorMessageInvalidPhone: `Por favor, introduce un número de teléfono válido sin paréntesis o guiones. Si reside fuera de Estados Unidos, por favor incluye el prefijo internacional (p. ej. ${CONST.EXAMPLE_PHONE_NUMBER}).`,
errorMessageInvalidEmail: 'Email inválido',
},
onfidoStep: {
acceptTerms: 'Al continuar con la solicitud para activar su billetera Expensify, confirma que ha leído, comprende y acepta ',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma

const isValidPhone = Str.isValidPhone(LoginUtils.appendCountryCode(searchValue));

const isValidEmail = Str.isValidEmail(searchValue);

if (searchValue && CONST.REGEX.DIGITS_AND_PLUS.test(searchValue) && !isValidPhone) {
return Localize.translate(preferredLocale, 'messages.errorMessageInvalidPhone');
}
Expand All @@ -874,6 +876,9 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma
if (/^\d+$/.test(searchValue) && !isValidPhone) {
return Localize.translate(preferredLocale, 'messages.errorMessageInvalidPhone');
}
if (/@/.test(searchValue) && !isValidEmail) {
return Localize.translate(preferredLocale, 'messages.errorMessageInvalidEmail');
}

return Localize.translate(preferredLocale, 'common.noResultsFound');
}
Expand Down

0 comments on commit c994994

Please sign in to comment.