Skip to content
Merged
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
12 changes: 11 additions & 1 deletion src/components/SubStepForms/FullNameStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TextInput from '@components/TextInput';
import useLocalize from '@hooks/useLocalize';
import type {SubStepProps} from '@hooks/useSubStep/types';
import useThemeStyles from '@hooks/useThemeStyles';
import {getFieldRequiredErrors, isRequiredFulfilled, isValidLegalName} from '@libs/ValidationUtils';
import {doesContainReservedWord, getFieldRequiredErrors, isRequiredFulfilled, isValidLegalName} from '@libs/ValidationUtils';
import HelpLinks from '@pages/ReimbursementAccount/USD/Requestor/PersonalInfo/HelpLinks';
import CONST from '@src/CONST';
import type {OnyxFormValuesMapping} from '@src/ONYXKEYS';
Expand Down Expand Up @@ -87,6 +87,11 @@ function FullNameStep<TFormID extends keyof OnyxFormValuesMapping>({
});
}

if (doesContainReservedWord(firstName, CONST.DISPLAY_NAME.RESERVED_NAMES)) {
// @ts-expect-error type mismatch to be fixed
errors[firstNameInputID] = translate('personalDetails.error.containsReservedWord');
}

const lastName = values[lastNameInputID as keyof FormOnyxValues<TFormID>] as string;
if (!isRequiredFulfilled(lastName)) {
// @ts-expect-error type mismatch to be fixed
Expand All @@ -101,6 +106,11 @@ function FullNameStep<TFormID extends keyof OnyxFormValuesMapping>({
limit: CONST.LEGAL_NAME.MAX_LENGTH,
});
}

if (doesContainReservedWord(lastName, CONST.DISPLAY_NAME.RESERVED_NAMES)) {
// @ts-expect-error type mismatch to be fixed
errors[lastNameInputID] = translate('personalDetails.error.containsReservedWord');
}
return errors;
},
[firstNameInputID, lastNameInputID, stepFields, translate],
Expand Down
Loading