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

Missing documentation for 'formValuesToJsonValues' #32

Open
rymeier opened this issue Aug 7, 2023 · 4 comments
Open

Missing documentation for 'formValuesToJsonValues' #32

rymeier opened this issue Aug 7, 2023 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@rymeier
Copy link

rymeier commented Aug 7, 2023

It looks like yall are trying to put this function in to the repo so it simplifies for those looking to implement your library. I have come across your library and I am using it for my SaaS platform. Its been good so far pretty straight forward with good enough documentation. How ever I am stuck on shaping the jsonValues in regards to the group-array type so I can get some validation running. Everything else is working fine with validation and errors for my form except for the nested inputs inside my group-arrays. How should I approach this or can you get me a developer preview on what the 'formValuesToJsonValues' function is going to look like that y'all are planning to ship with the library.

Example of Json Values I'm passing to handleValidation:

{ "club_code": "Dallas - Uptown", "team_member_last_name": "d", "team_member_email": "[email protected]", "team_member_street_address": "409 St", "team_member_city": "Bville", "team_member_state": "AK", "expense_details": [ { "amount": "32324", "receipt": "<redacted url>" } ] }

The group array expense_details has 5 required fields and the overall form has many required fields and returns back

{ "team_member_first_name": "Required field" }

Which is accurate for the main part of the form its just not validating my group-array.

Any assistance on this would be greatly appreciated. Also happy to provide more details as needed. Thanks.

@rymeier
Copy link
Author

rymeier commented Aug 8, 2023

The issue came down to me missing the type: "array" property on the group-array object when defining the form. But some better documentation around how the formValuesToJsonValues should work as well as the expected shape of the data getting passed into the handleValidation function would definitely be beneficial to the DX of when using your library.

@sandrina-p
Copy link
Collaborator

sandrina-p commented Aug 10, 2023

Hi @rymeier!
You are totally right, the formValuesToJsonValues needs better docs and examples.

But I must confess I didn't understand clearly your question. Was it about knowing the return shape of formValuesToJsonValues() or was it about knowing how to write the JSON Schema itself?

Could you share a sample of the JSON Schema that you have built?

If I understood correctly, you found out the bug: in your json schema it was missing type: "array" in the group-array field (expense_details).

Our backlog has a task to add more dev validations to the JSON Schemas structure (eg warn when type is missing). That would have saved you from being stuck.

@rymeier
Copy link
Author

rymeier commented Aug 10, 2023

Oh ya some more schema validation for missing properties definitely would have caught the silly mistake.

What I was originally asking for was the shape of the object returned by the formValuesToJson but seeing as it's really just looking for json maybe just some clarity and an example input into the function and how it should look after the fact. Something more real world would add confidence to the developer that they are understanding and building out that function correctly. Also sounds like you all might be adding that functionality into the library which would be stellar.

@sandrina-p
Copy link
Collaborator

Yes, we will. For transparency, I'll keep this issue open until the formValuesToJson is documented and/or released.

@sandrina-p sandrina-p added the documentation Improvements or additions to documentation label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants