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

input validation paterns #308

Open
errordeveloper opened this issue Dec 20, 2019 · 2 comments
Open

input validation paterns #308

errordeveloper opened this issue Dec 20, 2019 · 2 comments

Comments

@errordeveloper
Copy link
Contributor

errordeveloper commented Dec 20, 2019

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.

@brandonkal
Copy link

It is Javascript so you could use for instance:

  • superstruct
  • typescript-is
  • yup
  • ajv

@errordeveloper
Copy link
Contributor Author

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.

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

2 participants