Repository navigation
IOTA Watch: validating parallel upstream arrays before rendering rewards #6649
molimao
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I maintain IOTA Watch, an MIT-licensed training and mining monitor. One small Zod pattern in the project may be useful to other dashboards consuming external APIs.
Some upstream endpoints return several parallel arrays: an amount, timestamp and status at the same index form one reward record. Validating each array on its own is insufficient, because unequal lengths can silently pair the wrong values. Our helper builds a
z.object(shape)and adds a.refine()requiring all listed array lengths to match.The schemas also distinguish required numeric fields from optional or nullable metadata. Counts must be finite and nonnegative; loss is allowed to be null. A malformed payload produces an unavailable result instead of a plausible-looking zero. Successful previous data can be retained with its original source clock while the failure remains visible.
Schema definitions and alignment helper · data-reliability tests
This is a self-submitted application example, not a Zod extension. The UI is available in five languages and keeps reward units and accounting periods separate.
All reactions