12
votes
Accepted
Pythonic way for validating and categorizing user input
Don't print promiscuously. You've broken your problem down into several
small functions, which is a good general instinct. But you've undermined those
functions by polluting them with side effects -- ...
5
votes
Pythonic way for validating and categorizing user input
Your code is quite good, but there are two ways that it can be improved.
Single satisfication conditional checking
You use a lot of for loops in which you check if ...
4
votes
Accepted
Making an input validator function
Overall:
Good idea.
But your checks seem to be designed for machine input (not user input where a user could be told about the error and can then retry). But on the other hand you are prompting for ...
3
votes
Accepted
Find Invalid User Relationships in User to Manager Map (validate map as valid tree structure with no circular relationships)
Using TreeMap?
You have a tree represented in a HashMap, which is completely fine. A TreeMap has a specific tree structure based ...
2
votes
Accepted
Given an EAN-8 or an EAN-13 code, tell if that code is valid
You cite e.g. open.edu.
I would feel better about a citation to the (500 page!) EAN-{8,13} spec:
§ 7.9.1 and 7.9.5
(They are named GITIN-{8,13}, there.)
...
2
votes
Accepted
Validate that the console input contains positive integers only
First, I would suggest that when posting code for review that it be a complete. For example, variables blank_input and ...
2
votes
Making an input validator function
I like the idea; in fact, this is something I’ve considered doing myself from time to time.
Before I get into the review, I have to ask: why is this tagged C++14? It seems peculiar to tie yourself to ...
2
votes
Decorator to validate that Python function arguments are positive
The user-facing name should be substantive. Give it a name to convey its
behavior or purpose: require_positive_params() in the illustration below. On
a more ...
1
vote
About self validated Java POJOs
Content warning: this may be controversial and go against a lot of established practises.
I think you have figured out the advantages and disadvantages pretty well except for one thing. Having ...
1
vote
Accepted
Improved input validation function
After reading @indi explain what problem I have with my code I've fixed it in accordance with the comments he left. If anyone sees any more problems with it you are welcome to point it out.
The new ...
1
vote
Making an input validator function
I do not see a good reason for erroring when min == max.
Consider allowing the == case
...
Community wiki
1
vote
Decorator to validate that Python function arguments are positive
I am against decorators or partial wrappers and recommend type hints to restrict the expected types' values.
This way, a source code checker with a reasonable type hinting feature can detect issues ...
1
vote
Accepted
Search/Query API cross parameter check
The first thing I noticed is the use of the deprecated Date class instead of the LocalDate class that has been introduced with ...
1
vote
Search/Query API cross parameter check
You could wrap the request parameters in a class and then implement a custom validator that checks the dates.
That way, your controller's code would be reduced to:
...
1
vote
Form Validation Code Optimization in HTML and JavaScript"
You can simplify this a lot with proper markup and use of existing features.
General observations
Starting with general observations to the code, I noticed that you're writing everything in French.
...
1
vote
Given an EAN-8 or an EAN-13 code, tell if that code is valid
For those interested in the final solution I came up with: I have tweaked the implementation a bit, the logic remained the same though. The code is provided without any liability, warranty or license, ...
1
vote
Fill TextBox from ListBox on click
As I understand your description, the form loads without data. The user initiates the data loading by clicking a button and then they select the desired supplier. To me, that is asking the user to do ...
1
vote
Accepted
Theme picker for Laravel 8 blogging application
Is there any redundancy in my code?
There is some redundancy between $rules and $messages
This may not be an orthodox idea by ...
1
vote
Validate avatar image
Make unique exception sub-classes
It is good that ValidationException is declared as a subclass of Exception so that individual ...
1
vote
Chess Dictionary Validator (Python) (Automate The Boring Stuff)
This code will not work if in the board multiple pieces have the same position.
For example, below board contains 2 white pawns in the same position "3a". Even though the board is an invalid ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
validation × 730javascript × 147
php × 125
c# × 118
java × 97
python × 91
form × 73
beginner × 66
jquery × 62
object-oriented × 43
datetime × 33
regex × 33
c++ × 31
python-3.x × 31
ruby × 28
c × 27
strings × 27
email × 26
performance × 24
html × 22
.net × 21
ruby-on-rails × 21
error-handling × 20
security × 18
finance × 16