Skip to content

Commit

Permalink
Merge pull request Expensify#35229 from paultsimura/fix/35144-teacher…
Browse files Browse the repository at this point in the history
…s-name

fix: Use isValidPersonName for teachers name validation
  • Loading branch information
AndrewGable authored Jan 26, 2024
2 parents d4db5fc + e66f629 commit 62f4383
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,8 +1288,8 @@ export default {
dob: 'Please select a valid date of birth',
age: 'Must be over 18 years old',
ssnLast4: 'Please enter valid last 4 digits of SSN',
firstName: 'Please enter valid first name',
lastName: 'Please enter valid last name',
firstName: 'Please enter a valid first name',
lastName: 'Please enter a valid last name',
noDefaultDepositAccountOrDebitCardAvailable: 'Please add a default deposit bank account or debit card',
validationAmounts: 'The validation amounts you entered are incorrect. Please double-check your bank statement and try again.',
},
Expand Down
8 changes: 2 additions & 6 deletions src/pages/TeachersUnite/IntroSchoolPrincipalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ function IntroSchoolPrincipalPage(props: IntroSchoolPrincipalPageProps) {
(values: OnyxFormValuesFields<typeof ONYXKEYS.FORMS.INTRO_SCHOOL_PRINCIPAL_FORM>) => {
const errors: Errors = {};

if (!ValidationUtils.isValidLegalName(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', 'privatePersonalDetails.error.hasInvalidCharacter');
} else if (!values.firstName) {
if (!values.firstName || !ValidationUtils.isValidPersonName(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', 'bankAccount.error.firstName');
}
if (!ValidationUtils.isValidLegalName(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', 'privatePersonalDetails.error.hasInvalidCharacter');
} else if (!values.lastName) {
if (!values.lastName || !ValidationUtils.isValidPersonName(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', 'bankAccount.error.lastName');
}
if (!values.partnerUserID) {
Expand Down
14 changes: 5 additions & 9 deletions src/pages/TeachersUnite/KnowATeacherPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,21 @@ function KnowATeacherPage(props: KnowATeacherPageProps) {
(values: OnyxFormValuesFields<typeof ONYXKEYS.FORMS.I_KNOW_A_TEACHER_FORM>) => {
const errors = {};
const phoneLogin = LoginUtils.getPhoneLogin(values.partnerUserID);
const validateIfnumber = LoginUtils.validateNumber(phoneLogin);
const validateIfNumber = LoginUtils.validateNumber(phoneLogin);

if (!ValidationUtils.isValidLegalName(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', 'privatePersonalDetails.error.hasInvalidCharacter');
} else if (!values.firstName) {
if (!values.firstName || !ValidationUtils.isValidPersonName(values.firstName)) {
ErrorUtils.addErrorMessage(errors, 'firstName', 'bankAccount.error.firstName');
}
if (!ValidationUtils.isValidLegalName(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', 'privatePersonalDetails.error.hasInvalidCharacter');
} else if (!values.lastName) {
if (!values.lastName || !ValidationUtils.isValidPersonName(values.lastName)) {
ErrorUtils.addErrorMessage(errors, 'lastName', 'bankAccount.error.lastName');
}
if (!values.partnerUserID) {
ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.enterPhoneEmail');
}
if (values.partnerUserID && props.loginList?.[validateIfnumber || values.partnerUserID.toLowerCase()]) {
if (values.partnerUserID && props.loginList?.[validateIfNumber || values.partnerUserID.toLowerCase()]) {
ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'teachersUnitePage.error.tryDifferentEmail');
}
if (values.partnerUserID && !(validateIfnumber || Str.isValidEmail(values.partnerUserID))) {
if (values.partnerUserID && !(validateIfNumber || Str.isValidEmail(values.partnerUserID))) {
ErrorUtils.addErrorMessage(errors, 'partnerUserID', 'contacts.genericFailureMessages.invalidContactMethod');
}

Expand Down

0 comments on commit 62f4383

Please sign in to comment.