51 votes
Accepted

Password checker in Python

Concept Obligatory XKCD comic, before I begin: Enforcing password strength by requiring human-unfriendly characters is no longer considered good practice. Nevertheless, I'll review the code as you ...
user avatar
39 votes

Verifying a person's age

The biggest problem I see here is that you are printing a warning message to System.out and then using a default value for something which sounds like an Exception. ...
user avatar
35 votes

Regex validation for Email Address

I remember having read somewhere (possibly in another Code Review answer) that for an e-mail address, the simplest and most effective validation you can do is to make sure it contains an ...
user avatar
32 votes
Accepted

Accurate email syntax validation (no seriously)

"@"@example.com and "\ "@example.com both fail, but they are valid. ...
user avatar
  • 460
31 votes

Verifying IPv6 addresses

Python has a philosophy of "Batteries Included". Don't reinvent what's in the standard library! In particular, this code is much more easily written if we take advantage of ...
user avatar
  • 57.9k
28 votes
Accepted

Password validation in Java

Buggy behavior First you're checking the length of the passwords, and then if they are null: ...
user avatar
  • 107k
27 votes
Accepted

Verifying IPv6 addresses

You can change valid_characters to a string. 'ABCDEFabcdef:0123456789'. You can use ...
user avatar
  • 41.7k
24 votes

Password validation in Java

Your code is begging for the use of the Chain Of Responsibility patern (or rather, a variation of it). But first, some observations: You dereference the passwords before you check them for null: <...
user avatar
  • 96.7k
24 votes

Accurate email syntax validation (no seriously)

Said this in chat already, but @ succeeds even although it is not a valid email address. You should require at least 1 character in the local part and 1 character ...
user avatar
  • 22.2k
24 votes

Accurate email syntax validation (no seriously)

I personally find it hard to fault your code. Actually I'm quite surprised about the absence of code. Other than a few PEP8 errors there are three changes that I would recommend. You remove both <...
user avatar
  • 41.7k
24 votes
Accepted

Program to check if a date is valid or not

Good work! While there is certainly room for improvement, it is good that you stuck it out and discovered a solution on your own. ...
user avatar
  • 3,416
23 votes
Accepted

while(user == gullible)

A simple rule I (and other) try to apply is : define things in the smallest possible scope. For instance, int UserNumber = 0; can be moved inside the loop. ...
user avatar
  • 28.7k
22 votes
Accepted

Validating Yes/No answers in C++

You have a common bug that will send you into an infinite loop. :-) When reading data (especially user input data) you must validate the read worked correctly. If the read fails and sets one of the ...
user avatar
  • 91.7k
20 votes

Regex validation for Email Address

As @Simon pointed out, your regular expression might consider some valid addresses as invalid. Per this source which I've found somewhere on this Stack Overflow page, this would be RFC5322-compliant: ...
user avatar
20 votes
Accepted

A completely repetitive console prompt, a completely repetitive console prompt

String Formatting if (!requireValue) Console.Write(string.Format(message + " [{0}]: ", defaultValue)); else Console.Write(message + ": "); This innocent ...
user avatar
20 votes

Validating Yes/No answers in C++

For a beginner, that's very good code. There is one thing that almost all C++ programmers get wrong, and that's calling ::tolower with a ...
user avatar
  • 20.9k
19 votes
Accepted

Determining if all strings are parsable to int

I find that negatives in method names lead to confusing code. For instance, if (!ArePerPersonBILimitsInvalid(...)) "Are there no BI limits that are invalid?" ...
user avatar
  • 16.1k
19 votes

Checking if each char in a string is a decimal digit

In the cctype header, you have the std::isdigit(int) function. You can use this instead of your conditions that check if the ...
user avatar
  • 3,473
17 votes

Email validation using JavaScript

I disagree with rolfl's assertion that, "There is no practical way to validate an e-mail address by regex alone." He is correct—as illustrated by the somewhat infamous SO answer he linked to—that it'...
user avatar
  • 940
17 votes

E-mail testing code

First, heed what Jeroen Vannevel said; it will save you much grief. Of all the assumptions you've made here, only one is correct: there has to be an @ in the ...
user avatar
  • 20.3k
17 votes

"Suspicious comparison of integer references" while checking for a monotonically increasing sequence

You should only use == if you work with elementary data types (boolean, byte, char, short, int, long, float, long). If you use <...
user avatar
  • 2,060
17 votes

Accurate email syntax validation (no seriously)

You seems to build your module to contain only validate as "public" function. You may want to enforce that by declaring ...
user avatar
16 votes

"Who are you, and where do you live?" — a Q&A exercise

I have found a couple of things that could help you improve your code. Don't abuse using namespace std Putting ...
user avatar
  • 64.4k
16 votes

Checking if each char in a string is a decimal digit

The other reviews have hit most of the important points, so I'll just provide a single line alternative that uses the C++11 std::regex_match. That function looks ...
user avatar
  • 64.4k
16 votes
Accepted

Simple object validator

Instead of using regular expressions to manipulate the expression string I prefer to do expression manipulation. While this can be a little daunting at first it turns out to be fairly simple. It ...
user avatar
  • 745
15 votes

Can people understand my form validation code?

Can people understand my code? Its certainly not bad code - but I believe there are some things you can do which will improve the speed with which people like me can grasp what it is doing (and why). ...
user avatar
15 votes
Accepted

ISBN missing number solver

Overview Your code is generally pretty good, but there are places where it can be edited. Let's start off with... ...
user avatar
  • 9,414
15 votes

Password validation in Java

Something that I don't think has been mentioned: Don't return strings like that. The logic should be separate from the representation. So do something like ...
user avatar
  • 1,008
15 votes

while(user == gullible)

Given that the objective of the program is to waste time, I'm not sure that time efficiency is the thing to optimize for :P As far as anything else goes though there's room for improvement. I think ...
user avatar
  • 2,216
15 votes
Accepted

Is date 18+ years old?

What about this: function isDate18orMoreYearsOld(day, month, year) { return new Date(year+18, month-1, day) <= new Date(); } The ...
user avatar
  • 1,147

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