Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate name to avoid symbol character #26412

Merged
merged 4 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.


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