DEV Community

Discussion on: Optional booleans?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

If you use TypeScript probably also with runtypes, it's easy to do 'x' | 'y' | 'z', and all are truthy.

I believe API server should validate the input anyway (actually client-side as well), probably with JSON Schema and AJV.

But it might can be done with runtypes as well.