Skip to content

Commit

Permalink
Rework name regex on patient search page (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
katyasoup and pre-commit-ci[bot] authored Oct 28, 2024
1 parent 88ad9de commit 25af991
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions query-connector/src/app/query/components/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ const SearchForm: React.FC<SearchFormProps> = ({
[setUseCase],
);

const nameRegex = "^[A-Za-z\u00C0-\u024F\u1E00-\u1EFF\\-'. ]+$";
const nameRuleHint =
"Enter a name using only letters, hyphens, apostrophes, spaces, or periods.";

async function HandleSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
if (!fhirServer) {
Expand Down Expand Up @@ -191,9 +195,10 @@ const SearchForm: React.FC<SearchFormProps> = ({
</Label>
<TextInput
id="firstName"
title={nameRuleHint}
name="first_name"
type="text"
pattern="^[A-Za-z ]+$"
pattern={nameRegex}
value={firstName}
onChange={(event) => {
setFirstName(event.target.value);
Expand All @@ -210,9 +215,10 @@ const SearchForm: React.FC<SearchFormProps> = ({
</Label>
<TextInput
id="lastName"
title={nameRuleHint}
name="last_name"
type="text"
pattern="^[A-Za-z ]+$"
pattern={nameRegex}
value={lastName}
onChange={(event) => {
setLastName(event.target.value);
Expand Down

0 comments on commit 25af991

Please sign in to comment.