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

Validation/coercion on JSON decoding #216

Open
dittos opened this issue May 28, 2022 · 0 comments
Open

Validation/coercion on JSON decoding #216

dittos opened this issue May 28, 2022 · 0 comments

Comments

@dittos
Copy link

dittos commented May 28, 2022

decodeJson should validate or coerce field values based on type to guarantee runtime type safety.

For example,

  • reject non-numeric strings in the place of int* fields
  • coerce numeric strings to number in the place of int* fields
  • coerce non-string values to string in the place of string fields
  • reject (or coerce to zero) unknown enum const
  • (...or at least throw if runtime type does not match compile time type)

This is not supported yet AFAIK. https://github.com/pbkit/pbkit/blob/3b3a42a7d5b535defbdf176e68e47cfe8b4a8a7e/core/runtime/json/scalar.ts

Some of the behavior is documented (but not well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant