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 -- ...
FMc's user avatar
  • 12.5k
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 ...
Ξένη Γήινος's user avatar
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 ...
Martin York's user avatar
  • 94.3k
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 ...
IWilms's user avatar
  • 226
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.) ...
J_H's user avatar
  • 16.7k
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 ...
Booboo's user avatar
  • 749
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 ...
indi's user avatar
  • 10.2k
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 ...
FMc's user avatar
  • 12.5k
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 ...
TorbenPutkonen's user avatar
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 ...
globalturist's user avatar
1 vote

Making an input validator function

I do not see a good reason for erroring when min == max. Consider allowing the == case ...
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 ...
Richard Neumann's user avatar
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 ...
dariosicily's user avatar
  • 3,931
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: ...
Miguel Alorda's user avatar
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. ...
Ismael Miguel's user avatar
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, ...
Droidman's user avatar
  • 153
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 ...
Paul Stoner's user avatar
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 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
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 ...
tom varghese's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible