Skip to main content

Questions tagged [validation]

Validation is used to check data to make sure it fits whatever required specifications are set for it.

Filter by
Sorted by
Tagged with
62 votes
6 answers
5k views

Accurate email syntax validation (no seriously)

So a friend happened to show me how odd and specific the general email syntax rules are. For instance, emails can have "comments". Basically you can put characters in parentheses that are just ignored....
SuperBiasedMan's user avatar
57 votes
5 answers
37k views

Verifying password strength using JavaScript

I have a function which verifies the "Password" field and suggests the user to enter a strong password. I also have a label named "Password Strength", referring to the strength of a password (very ...
Pavan's user avatar
  • 705
36 votes
3 answers
11k views

Ensuring user input is an integer in a range

I have isolated a little bit of code that was causing a small debate between myself and another user. I have taken some of the things that he said and meshed it with the code that was being reviewed ...
Malachi's user avatar
  • 28.7k
31 votes
7 answers
56k views

Password validation in Java

I just wrote this password validation code function that checks to see if a password will be accepted in AD or not. I'm not sure this is the best way to do it, but for now it works fine. I would love ...
pt18cher's user avatar
  • 651
31 votes
5 answers
4k views

A completely repetitive console prompt, a completely repetitive console prompt

So I wrote this for my Mandelbrot Generator, to collect and use input from the user, and I made it dynamic enough to be useful anywhere. I'm really interested in all critiques of it, as I'm going to ...
Der Kommissar's user avatar
30 votes
2 answers
37k views

Password checker in Python

Using Python 2.7.12 I wrote a simple little script, psk_validate.py, that prompts the user for a potential password and checks if it has upper and lower-case ...
MadHatter's user avatar
  • 837
28 votes
6 answers
9k views

Matching a generated string of random letters to an input

I made a program in Python and wanted it to be faster, so I wrote it on C# because it's compiled. To my surprise, the Python program is much faster. I guess there is something wrong with my C# code, ...
bobpal's user avatar
  • 383
28 votes
6 answers
28k views

Validating opening and closing bracket pairs

I have refactored one of my old homework assignments (mainly to utilize std::stack and some C++11), and I'm still having trouble making it less repetitive. It ...
Jamal's user avatar
  • 34.9k
24 votes
10 answers
4k views

Verifying a person's age

When coding I noticed I started to get into a habit of not using if-else statements when the else block only has one line of code. For example, if I have code that can be solved like this: ...
Russ Wilkie's user avatar
23 votes
6 answers
15k views

Validating Yes/No answers in C++

I intend to accept all of the following answers: y Y yes YES Yes plus mixtures, such as yeS, yES, which I didn't intend to accept but it's a consequence of my code the same applies to No and its ...
Vlastimil Burián's user avatar
23 votes
4 answers
2k views

Celsius → Fahrenheit conversion table

It's harder to do than criticize. Here's my attempt to implement a Celsius-to-Fahrenheit conversion table in C++. ...
200_success's user avatar
22 votes
7 answers
33k views

Check for balanced parentheses

I was given an assignment to check for balanced parentheses from an arbitrary string where parentheses are defined as (, [ or { and their respective "closing" ...
Overly Excessive's user avatar
21 votes
8 answers
47k views

Program to check if a date is valid or not

I am a novice programmer and am currently learning Python programming by myself through a book. I stumbled upon a question in a chapter and it took me 2 days to figure out a solution for it. Although, ...
mathlover92's user avatar
21 votes
2 answers
2k views

Allowing users to input a safe subset of HTML

I am currently working on a project that requires users to input text that may or may not be formatted (if it helps, just think of it as a Stack Exchange clone, even though that's not quite accurate). ...
Meredith's user avatar
  • 294
20 votes
6 answers
16k views

Simple object validator

I wrote a simple validation tool that allows me to quickly define validation rules and check my data objects against them. I know there is this another tool called FluentValidation but... I'm not a ...
t3chb0t's user avatar
  • 44.3k
20 votes
3 answers
5k views

Credit card verification: string conversion most optimal?

Below is some code which verifies a credit card number using the checksum as well as check if number of digits are appropriate as well if digits start with right numbers. I am not sure if converting ...
Andy's user avatar
  • 583
20 votes
2 answers
49k views

Email validation using JavaScript

I have a function where I validate emails via a regex. I was wondering if this is the best regex to use or if there's a better way of doing it. Also is there a ...
pt18cher's user avatar
  • 651
19 votes
2 answers
1k views

Enforcing string validity with the C# type system

One of my biggest complaints about .NET is that there's no way to guarantee a string match a certain type in the type-system. Note This started as more of a proof-of-concept than a real usable system,...
Der Kommissar's user avatar
18 votes
7 answers
20k views

Checking if each char in a string is a decimal digit

I had to write a program that would verify that a string contains any digits beside numbers 0-9 and the first '-' sign to indicate if pos/neg. The algorithm works like I want it to, but is there a ...
rchkrvr2's user avatar
  • 181
18 votes
3 answers
12k views

Credit card validator using Luhn's algorithm

I'm writing an algorithm to read from a file a list of numbers, and for each, determine if it is valid. If it is, then display which card type it is. ...
Ryan Dougherty's user avatar
17 votes
6 answers
14k views

Verifying IPv6 addresses

While trying to learn Python I stumbled upon a question which asks you to write a code that is able to take an input and verify it to see whether it meets the IPv6 Criteria. I wrote the following ...
Nauman Shahid's user avatar
17 votes
2 answers
7k views

ISBN missing number solver

This is a programming contest question. Question as follows Problem Definition An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first 9 ...
Anirban Nag 'tintinmj''s user avatar
16 votes
4 answers
1k views

Determining if all strings are parsable to int

I have to loop through a list of strings and validate that all are parsable to int and not less than 1. Also, if a string is ...
Charu's user avatar
  • 337
16 votes
6 answers
74k views

Is it better practice to have void method throw an exception or to have the method return a boolean?

This falls straight into the same category with the recent "Is it better practice to return if false or execute an if statement if true?" question. Often, while writing code, I find myself presented ...
ZeroOne's user avatar
  • 1,262
15 votes
3 answers
42k views

Sudoku Checker in Java

...
user3296744's user avatar
15 votes
2 answers
986 views

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

This is my first attempt at a programme. Is it good form? Does it follow best practice? Or am I completely off the mark? ...
Barrie's user avatar
  • 151
14 votes
7 answers
48k views

Regex validation for Email Address

I need to validate whether my regex is correct for below scenario. Suggestion's if the regex is correct: Wiki Link Local_part The local-part of the email address may use any of these ASCII ...
Idothisallday's user avatar
14 votes
5 answers
35k views

Validating integer or string input

I'm at uni and working on an assignment in c# that takes some user input (from they keyboard via console). The input validation required: numbers must be within range (range will vary depending on ...
Mathew Harrington's user avatar
14 votes
2 answers
864 views

Input validation for a user

I have a small Person Domain Model as follows: ...
Randy's user avatar
  • 487
14 votes
3 answers
24k views

Validating Excel file columns

I'm looking for ways to improve this code (more readable, less redundant and maybe cleaner/faster). The problem I needed to solve: I was designated to implement a software that is going to validate ...
Bsarkis's user avatar
  • 143
14 votes
1 answer
35k views

Click event function that checks to see if form field is valid

What I'm building is a URL builder. A marketing person inputs a URL and can test that URL to see if it's valid, then they select a demand channel and then hit 'Generate Campaign URL'. I've omitted the ...
Blexy's user avatar
  • 540
13 votes
4 answers
2k views

C Program which compares software version strings

I wrote the following C program to compare software version strings. Please provide any general feedback you'd like, but with special focus on error handling decisions, user input validation/...
the_endian's user avatar
  • 1,343
12 votes
6 answers
4k views

while(user == gullible)

The goal for this project was to: Write a program that continues to asks the user to enter any number other than 5 until the user enters the number 5. Then tell the user "Hey! you weren't ...
Chantola's user avatar
  • 429
12 votes
5 answers
2k views

E-mail testing code

I made some code to check that e-mails given apply to the right format, and I'm sure there must be a better way to do this. ...
Pablito's user avatar
  • 229
12 votes
5 answers
6k views

Credit card validation

I started following Harvard's CS50 (Introduction to Computer Science) on edX, and as part of their Hacker edition set 1 was the following assignment: I am supposed to write a program (in C), that ...
Stefan Rendevski's user avatar
12 votes
3 answers
79k views

Validate and import data from an Excel file

I have recently designed a module which will do bulk upload for different contents. Basically the user will upload an Excel file, I will have to read and validate headers of excel then each value of ...
VIckyb's user avatar
  • 665
12 votes
3 answers
3k views

Pythonic way for validating and categorizing user input

In multiple parts of my program, user input needs to be validated and categorized. As these "validation trees" can get pretty unwieldy, I've started splitting them out in different functions,...
Jan van Wijk's user avatar
12 votes
5 answers
12k views

Validation that also returns error messages

My Create, Update and Delete methods should return a ...
Coder Absolute's user avatar
12 votes
2 answers
1k views

Foolproof number validation

I know there have been a lot of post, blog article answer on Stack Overflow (but the validation does return true on a tab character) about this. But I'm still ...
David Laberge's user avatar
12 votes
1 answer
319 views

Bitcoin address validator in C

Here is a Bitcoin address validator I am looking to have reviewed in C. Normally I would have the enum and function prototypes declared in a header file, but I ...
syb0rg's user avatar
  • 21.8k
11 votes
8 answers
2k views

Check whether address criteria contain only certain fields or more

I have a method that checks whether an addressCriteria contains only certain fields or more. If it contains more fields, it should return false, otherwise true. I'...
JREN's user avatar
  • 272
11 votes
7 answers
3k views

Versatile string validation

I passed a technical test the other day, one part included a cheap string validation and I am wondering this can be further improved to be more versatile to requirement changes. The requirements were ...
Natalie Perret's user avatar
11 votes
5 answers
9k views

Birthday validity-checking

I have written code to check any birthday input's validity. As I am new in programming, and after going through several debugging steps, the code became very ugly. ...
Sheikh Ahmad Shah's user avatar
11 votes
3 answers
323 views

Proper way to validate from sub to sub

I am using a public validating sub to help validate the other subs. Is this the most efficient way to do this? ...
FoxMcCloud's user avatar
11 votes
3 answers
3k views

Bank card validation module

I hope that someone could review a module I wrote for bank card validation. I included a class that tests some of the methods, which is purely to show the methods work, rather than unit testing. ...
NRKirby's user avatar
  • 225
11 votes
5 answers
46k views

Checking whether a string is a valid number

I'm developing a Java Helper Library which has useful methods developers don't want to type out over and over. I'm trying to think of the best way of checking whether a string is a valid number. I've ...
kentcdodds's user avatar
11 votes
3 answers
436 views

Preconditions library

Over the past year I've quietly developed a library for checking method preconditions. The project is hosted at https://bitbucket.org/cowwoc/preconditions/ I would like to get your feedback on the ...
Gili's user avatar
  • 219
11 votes
2 answers
1k views

C library for standard input operations with data validation and error check

I have implemented a C library to perform basic input operations on built-in data types with various error checks of more complexity. Any improvements or suggestions are appreciated. GitHub ...
user avatar
11 votes
2 answers
4k views

A general purpose GUI data input, with validation, but unclear about best object design

When I'm throwing together prototype code, I don't want to spend extra time setting up parameters, or chasing down problems from entering parameters wrongly. So this is a general purpose, fairly easy ...
Neil_UK's user avatar
  • 343
11 votes
2 answers
324 views

Verify that a path doesn't contain . or .. or // and doesn't end with /

This is actually a function from the first commit of the git source code, for the purpose stated in the title: ...
vijairaj's user avatar
  • 213

1
2 3 4 5
15