codeforboston / home-energy-analysis-tool

https://www.codeforboston.org/projects/
MIT License
12 stars 31 forks source link

Discuss how to use `?.` (js optional chaining operator) #258

Open plocket opened 1 month ago

plocket commented 1 month ago
          Future issues:
  1. Remove ?. optional chaining operator from user_data
  2. How do we want to handle ?. optional chaining operators in general? They indicate that something is not as expected, which will have consequences somewhere in the code. Those cases should be handled.

_Originally posted by @plocket in https://github.com/codeforboston/home-energy-analysis-tool/pull/255#discussion_r1783658329_

thiagobardini commented 1 month ago

The solution to this problem is to use Zod validation, as shown in the link below. We already have the validation in place, we just need to adjust it, which is why we're seeing conflicts.

Posted comment by @thiagobardini in https://github.com/codeforboston/home-energy-analysis-tool/pull/255#discussion_r1783748637

plocket commented 1 month ago

From https://github.com/codeforboston/home-energy-analysis-tool/pull/255#discussion_r1792622597

Briefly talked about tradeoffs of using optional in meeting, esp mentioning required form fields being driven by Zod. To me that means if we take the .optional() approach, we may need multiple zod objects for the same piece. Let's cover this in #258

From now, let's keep this convo in here