ianstormtaylor / superstruct

A simple and composable way to validate data in JavaScript (and TypeScript).
https://docs.superstructjs.org
MIT License
6.97k stars 224 forks source link

Fixes #971 - nested coercion #1038

Closed kmannislands closed 1 year ago

kmannislands commented 2 years ago

Started with a failing test per @yss14's example in the ticket

Tried implementing an entries generator per @ianstormtaylor's suggestion but it didn't seem to do the trick.

Seems @poyangliu was correct: the issue is that the coerce bit of context wasn't being propagated in the call to validate() in the run() method. Added it to the argument to validate though I'm not sure this is the correct approach. Perhaps coerce and mask should be optional members of Context in general?

Closes #971