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

Updates contact form validation to match to backend #446

Merged
merged 6 commits into from
Nov 29, 2023

Conversation

mohitb35
Copy link
Contributor

@mohitb35 mohitb35 commented Nov 9, 2023

Resolves errors faced due to mismatch in server/client validation for the contact form fields

Changes:

  1. Updates validation rules in contact form fields
  2. Removes redundant error displaying code and standardizes logic by using errors.{fieldname}.message
  3. Updates error messages and styles to handle longer messages
  4. Adds dependencies
    a. hookform/devtools to debug rhf forms when needed
    b. babel/plugin-transform-unicode-regex - to allow unicode regexp patterns as used in server validation

- hookform/devtools to debug the rhf forms
- babel/plugin-transform-unicode-regex to enable unicode regexp
- updates contact form validation rules
- updates error text
- stores error messages in error.fieldname.message to reduce duplication
- updates form-error styles to enable longer messages
- GiftForm.tsx
- OnBehalf.tsx
Copy link

vercel bot commented Nov 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
donate-with-planet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2023 3:10pm

@prachigarg19
Copy link
Collaborator

prachigarg19 commented Nov 10, 2023

I was able to add just - as a valid value in first name and last name. Is this the expected behavior?

image

Same goes for company name, I'm able to add just a special character as a valid value.

@mohitb35
Copy link
Contributor Author

I was able to add just - as a valid value in first name and last name. Is this the expected behavior?

image

Same goes for company name, I'm able to add just a special character as a valid value.

Ideally should not be possible, but I'm trying to match the validation to the backend.

@jmiridis @mariahosfeld should we update this to prevent special characters at the start of the first name, last name, and company name?

@mariahosfeld
Copy link
Contributor

I was able to add just - as a valid value in first name and last name. Is this the expected behavior?
image
Same goes for company name, I'm able to add just a special character as a valid value.

Ideally should not be possible, but I'm trying to match the validation to the backend.

@jmiridis @mariahosfeld should we update this to prevent special characters at the start of the first name, last name, and company name?

Even though it might be an edge case, I think for first name & last name we should prevent.

@mariahosfeld
Copy link
Contributor

I was able to add just - as a valid value in first name and last name. Is this the expected behavior?

image

Same goes for company name, I'm able to add just a special character as a valid value.

For company name it is okay, we need to allow starting with a special character.

Copy link
Contributor

@mariahosfeld mariahosfeld left a comment

Choose a reason for hiding this comment

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

Tested functionality regarding communication as well as general behavior, everything works for me as expected.

- disallows entries beginning with special characters
@mohitb35
Copy link
Contributor Author

I was able to add just - as a valid value in first name and last name. Is this the expected behavior?
image
Same goes for company name, I'm able to add just a special character as a valid value.

For company name it is okay, we need to allow starting with a special character.

Resolved in 83413f1

@prachigarg19
Copy link
Collaborator

lgtm

Copy link
Collaborator

@norbertschuler norbertschuler left a comment

Choose a reason for hiding this comment

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

Seems to work (commented possible clean ups)

@@ -53,6 +53,8 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@babel/plugin-transform-unicode-regex": "^7.22.5",
"@hookform/devtools": "^4.3.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still necessary after you commented the import in the code below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not needed. but it makes it easier to debug react hook form when necessary.

@@ -19,6 +19,7 @@ import { AddressCandidate, GeocodeSuggestion } from "src/Common/Types/arcgis";
import GiftIcon from "public/assets/icons/GiftIcon";
import { euCountries } from "src/Utils/countryUtils";
import { isEmailValid } from "src/Utils/isEmailValid";
// import { DevTool } from "@hookform/devtools";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just remove this line or do you want to keep it as some form of documentation on how to debug?

Copy link
Contributor

@mariahosfeld mariahosfeld left a comment

Choose a reason for hiding this comment

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

Lgtm

@mariahosfeld mariahosfeld merged commit 330e4de into develop Nov 29, 2023
5 checks passed
@mariahosfeld mariahosfeld deleted the feature/update-contact-form-validation branch November 29, 2023 09:45
@mariahosfeld mariahosfeld mentioned this pull request Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants