Skip to content

Commit

Permalink
Merge pull request #26412 from dukenv0307/fix/26275
Browse files Browse the repository at this point in the history
Validate name to avoid symbol character
  • Loading branch information
marcochavezf authored Sep 4, 2023
2 parents 91ff78d + 72e08c5 commit f992844
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/pages/TeachersUnite/IntroSchoolPrincipalPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ROUTES from '../../ROUTES';
import Navigation from '../../libs/Navigation/Navigation';
import TeachersUnite from '../../libs/actions/TeachersUnite';
import useLocalize from '../../hooks/useLocalize';
import * as ValidationUtils from '../../libs/ValidationUtils';

const propTypes = {
/** Login list for the user that is signed in */
Expand Down Expand Up @@ -53,10 +54,14 @@ function IntroSchoolPrincipalPage(props) {
(values) => {
const errors = {};

if (_.isEmpty(values.firstName)) {
if (!ValidationUtils.isValidLegalName(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', translate('privatePersonalDetails.error.hasInvalidCharacter'));
} else if (_.isEmpty(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', translate('bankAccount.error.firstName'));
}
if (_.isEmpty(values.lastName)) {
if (!ValidationUtils.isValidLegalName(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', translate('privatePersonalDetails.error.hasInvalidCharacter'));
} else if (_.isEmpty(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', translate('bankAccount.error.lastName'));
}
if (_.isEmpty(values.partnerUserID)) {
Expand Down
9 changes: 7 additions & 2 deletions src/pages/TeachersUnite/KnowATeacherPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ROUTES from '../../ROUTES';
import Navigation from '../../libs/Navigation/Navigation';
import TeachersUnite from '../../libs/actions/TeachersUnite';
import useLocalize from '../../hooks/useLocalize';
import * as ValidationUtils from '../../libs/ValidationUtils';

const propTypes = {
/** Login list for the user that is signed in */
Expand Down Expand Up @@ -64,10 +65,14 @@ function KnowATeacherPage(props) {
const phoneLogin = LoginUtils.getPhoneLogin(values.partnerUserID);
const validateIfnumber = LoginUtils.validateNumber(phoneLogin);

if (_.isEmpty(values.firstName)) {
if (!ValidationUtils.isValidLegalName(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', translate('privatePersonalDetails.error.hasInvalidCharacter'));
} else if (_.isEmpty(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', translate('bankAccount.error.firstName'));
}
if (_.isEmpty(values.lastName)) {
if (!ValidationUtils.isValidLegalName(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', translate('privatePersonalDetails.error.hasInvalidCharacter'));
} else if (_.isEmpty(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', translate('bankAccount.error.lastName'));
}
if (_.isEmpty(values.partnerUserID)) {
Expand Down

0 comments on commit f992844

Please sign in to comment.