Plant-for-the-Planet-org / planet-donations

The Donation Gateway that powers the Plant-for-the-Planet Platform. You can make donations to restoration organizations, plant trees and support forest conservation.
https://donate.plant-for-the-planet.org
Other
7 stars 5 forks source link

Updates contact form validation to match to backend #446

Closed mohitb35 closed 11 months ago

mohitb35 commented 1 year ago

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
vercel[bot] commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.

mohitb35 commented 11 months ago

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 https://github.com/Plant-for-the-Planet-org/planet-donations/pull/446/commits/83413f137e91d2de08af48847c1f21fda889156a

prachigarg19 commented 11 months ago

lgtm