input validation paterns
If I read e.g. a JSON file as input, or some -p variables, what is the best way for me to validate what I have and produce meaningful errors to the user? I suppose I can just write it myself and throw exceptions, but it would tedious and I wish I didn't have to write too much code, or if there was a documented patter that I could copy instead of having to invent something.
It is Javascript so you could use for instance:
- superstruct
- typescript-is
- yup
- ajv
I guess to me it's be handy if I could declare parameters with a schema of some sort, and get validation from just calling param.String("foo", "bar", "(bar|foo)").
Another thing that does trip me up right now is that when I read YAML or JSON in TypeScript, I cannot assert it agains a particular type and non-optional fields come out as undefined.