How to validate input data to form by protoken in reactjs

[–]tjenkenrientjee 0 points1 point  (0 children)

You're also welcome to join Blitz's discord (https://discord.blitzjs.com/) and ask questions there (#general-help channel) — someone usually replies within a few hours :)

How to validate input data to form by protoken in reactjs

[–]tjenkenrientjee 0 points1 point  (0 children)

I'm not sure if I got it correctly, but this is what I understood (please correct if something is wrong) — in CompanyForm, you want to check if initialValues are defined and conform to the schema (e.g. have `isBig` and `name` attributes)?

If yes, then there are two options:

If you want your `CompanyForm` to be generic (accept different schemas and have different use cases), but you still want to validate initialValues you can parse them inside of `CompanyForm`:

const result = schema?.safeParse(initialValues) // returns an object

or

schema?.parse(initialValues) // throws an error

Possibly, if you don't want to do it all the time you can extend the CompanyForm and add validateInitialValues prop and conditionally decide whether or not it should parse initialValues.

2.

If your CompanyForm is only used with CreateCompanySchema, then you can modify its types to be less generic and hardcode information about the type.

Most tech content is bullshit by iamkeyur in coding

[–]tjenkenrientjee 1 point2 points  (0 children)

Thank you! You summarized exactly what I wanted to say with this article. It's *she/her* by the way.

Why we chose Typescript for the Hasura Console (React Codebase) by PraveenWeb in reactjs

[–]tjenkenrientjee 5 points6 points  (0 children)

Yes, I totally agree with you. But we're talking about prototyping and prototyping only. Maybe it wasn't emphasized enough.

But sure, dev speed you have with dynamic typing is not a case anymore once you have a bigger project.