-
Notifications
You must be signed in to change notification settings - Fork 41
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
Best effort validation of user input #29
Conversation
Unfortunately, I haven't found a better way. Having said that, it's entrirely possible this is going to fall short.
Commit adds best effort validation of user input. Should the input be invalid, defaults will be used instead for sanity.
First of all and as before, I'm no Java programmer. Second, I haven't found a better way to validate user input than to do it this way, resp. via @jovandeginste, please, can you give this a look? |
Commit refactors input validation in constructor. Logic has been moved into respective functions and code has been simplified. Commit also adds unit tests to prove code in question works as expected.
I have refactored the code a bit and added unit tests. Unfortunately, I have no idea how to write unit tests for form validation part. |
... or @jippi ? |
@zstyblik Due to personal stuff, I'm taking some slow weeks. As a default, I would rather have the code throw errors than do something I didn't expect it to do. |
@jovandeginste sure, no problem.
I'm open to suggestions. However, Java exception says pretty much nothing to the user like any exception from any programming language and code you're not familiar with. In other words, I really hate when Jenkins goes exception on me for no obvious reason. EDIT: Let me rephrase it a bit. I'm talking about communicating the error to the user. Defaults are used as the last line of defense when form validation errors are ignored and form is submitted regardless. If it's possible to raise exception which is easy to understand by the user, let's do that. |
a326e2d
to
19e8175
Compare
PR adds best effort validation of user input. Fall back to sane defaults in case of invalid input.
Fixes #22