Skip to main content
The 2024 Developer Survey results are live! See the results

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
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
0 votes
1 answer
146 views

Advent of Code 2020 - Day 2: validating passwords

Previous: Advent of Code 2020 - Day 1: finding 2 or 3 numbers that add up to 2020 Next: Advent of Code 2020 - Day 3: tobogganing down a slope Problem statement I decided to take a shot at Advent of ...
L. F.'s user avatar
  • 9,570
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
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
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
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
6 votes
1 answer
119 views

Validating a StreamingPin

Recently I was thinking about the keyless entry on my car and how simple it has to be, so I wrote a C# programme to validate a StreamingPin, that is, a pin that is ...
Der Kommissar's user avatar
6 votes
2 answers
1k views

Google reCAPTCHA Validator: Iteration II

This is a follow-up to the other post I made (less than an hour ago) about my Google reCAPTCHA C# implementation: Google reCAPTCHA Validator This adds support for error messages, so that you can ...
Der Kommissar's user avatar
3 votes
1 answer
153 views

Newspaper Bill Calculator CLI with Python (2 of 3, CLI)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 1 of 3, Core: Newspaper Bill ...
eccentricOrange's user avatar
3 votes
1 answer
289 views

Date validation in Java

I'm learning Java, and would really appreciate any tips on how to improve this code. It's just a simple date validation class. ...
Nilzone-'s user avatar
  • 1,426
2 votes
1 answer
108 views

Newspaper Bill Calculator CLI with Python (1 of 3, Core)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 2 of 3, CLI: Newspaper Bill ...
eccentricOrange's user avatar
2 votes
1 answer
190 views

Date validation in Java - take two

I read through and implemented the advice I received yesterday. I would, once again, really like some input on how this can be improved. e.g. encapsulation, interfaces, abstract classes etc.. Right ...
Nilzone-'s user avatar
  • 1,426
1 vote
1 answer
51 views

UPDATE on Newspaper Bill Calculator CLI with Python (2 of 3, CLI)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 1 of 3, Core: UPDATE 1 on Newspaper ...
eccentricOrange's user avatar
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
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
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
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
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
10 votes
4 answers
10k views

Password checker in PHP

I have written a password checker using PHP, consisting of many if else statements. Is there any possible way to shorten this code? ...
user3326060's user avatar
10 votes
2 answers
981 views

Monad transformers in C# for use in validation

I am working on using monad transformers in C#. I would like to know if the following code I present, shows that I have understood this. I am fairly new to this so any feedback / comments are really ...
Blair Davidson's user avatar
8 votes
3 answers
225 views

Check Accounting Journal for Errors

I wrote this sub in Excel VBA. I am a novice, but I was able to get my code to work how I wanted it to. Unfortunately, I can see there is a lot of repetition, but it is too complex for me to ...
luckyguy73's user avatar
8 votes
3 answers
414 views

Unicode Chess PvP with Move Validation

Main Purpose This script allows two players to play chess on a virtual chessboard printed on the screen by making use of the Unicode chess characters. Visual appearence ...
Caridorc's user avatar
  • 27.5k
8 votes
4 answers
8k views

Reducing boilerplate when validating parameters and using a tuple for the parameter list of a case class

I had designed a simple case class that looks like this: case class StreetSecondary(designator: String, value: Option[String]) I needed to add validation (to ...
chaotic3quilibrium's user avatar
7 votes
1 answer
107 views

Streaming a Pin functionally(ish)

Earlier today I wrote a question (Validating a StreamingPin) and I thought it was a good idea (apparently I was the only one who thought so, but whatever), so I proceeded further with it and developed ...
Der Kommissar's user avatar
7 votes
1 answer
2k views

Credit card validation - Python 3.4

Just completed a piece of code - a credit card validation program in python - as a little side project. Having no experience with classes in the past, I decided to employ classes in this project. I ...
EugeneProut's user avatar
7 votes
3 answers
3k views

Fluent Validation of Objects

Inspired by this question by t3chb0t and as an elaboration of my own answer, I have written the following solution. My goal was to reduce complexity both in implementation and use. Eventually - I have ...
user avatar
7 votes
2 answers
296 views

Test if string is numeric

I want to implement the following function: ...
Arun's user avatar
  • 171
6 votes
4 answers
280 views

A C# struct representing a string that can be neither null nor white space

I've written a C# struct in order to encapsulate the idea of a string being neither null nor ...
Enrico Massone's user avatar
6 votes
3 answers
209 views

Weekday+day validation

The string I'd like to check is something like "abcSun24def". If any valid "xxxyy" (xxx = weekday and yy = day) is found, return the position inside the string. If "xxxyy" is not found, return -1. ...
geohei's user avatar
  • 245
6 votes
2 answers
343 views

A way to handle integer input

I'm working on simple code that is to read input where: The first line is a number of cases to consider. The next lines are integers separated by a space that will be tested lately. Possible input: ...
Jacob's user avatar
  • 371
6 votes
2 answers
250 views

Simplifying this form validation script

Can anyone please help me to simplify this form validation script? It works great but I was just wondering if I can get some help to make it simpler. Your opinion on the approach I used below is ...
Leo's user avatar
  • 789
6 votes
3 answers
441 views

Simple object validator with a new API

Quite some time ago I have created the Simple object validator (see also self-answer). The more I used it the more I thougt its API could be better so I have heavily refactored it and would like to ...
t3chb0t's user avatar
  • 44.3k
5 votes
2 answers
526 views

Validating a password format

How should I make this more Ruby-like or just "better"? ...
Douglas Birch's user avatar
5 votes
3 answers
2k views

Validating a credit card number using Luhn's algorithm

I implemented Luhn's algorithm explained on Wikipedia to validate a credit card number, in Bash. Does this code follow good practices? ...
智障的人's user avatar
5 votes
1 answer
4k views

Class-based user input validation

Having contributed to this Community Wiki on StackOverflow regarding validating user input, I thought I'd finally sit down and write something more robust to do these kinds of tasks. I wanted ...
jonrsharpe's user avatar
  • 13.9k
5 votes
2 answers
362 views

Is there a better way to optimize these conditionals?

...
Luis's user avatar
  • 161
5 votes
1 answer
866 views

Validation extensions v2

I have still another version of my validation extensions. I've reworked it and added some new features. It doesn't relay on expression trees any more but as a compensation the same extensions can be ...
t3chb0t's user avatar
  • 44.3k
4 votes
1 answer
2k views

Luhn algorithm MS-SQL

This a solution Luhn algorithm for credit validation. This algorithm is a basic one inspired by wikipedia. I mean no check for length, type, and so on. You can enhance the base code as you want it to ...
Modhaffer's user avatar
4 votes
2 answers
2k views

Credit card checking

I am practicing test-driven development in Python. Feedback about both the tests and the code is appreciated. I'm using luhn algorithm and regex to check credit card numbers for validity. Here are ...
mcgyver5's user avatar
  • 638
4 votes
3 answers
2k views

Hold and validate an EAN13 code

I've created a class that holds an EAN13 code. This class is an attribute of the Product class. In the Ean13 class, the ...
alexpfx's user avatar
  • 524
4 votes
2 answers
842 views

Big Nerd Ranch Bronze Challenge: Disallow Alphabetic Characters

I just completed BNR's bronze challenge for disallowing alphabetic characters, and would love some feedback on what I did right and wrong, and how I can improve my code for reusability and ...
Justin Jaster's user avatar
4 votes
1 answer
148 views

Constraining a property setter fluently

The below code is aimed at providing you the most amount of control and flexibility with control which value gets set to a property. I Introduce to you, the ...
BanMe's user avatar
  • 75
4 votes
1 answer
118 views

Validating company registration numbers

N.B. The next stage of this project, which covers parsing filenames and checking numbers against the list produced in this question, is covered here. I have a list of company numbers (UK companies ...
Kaz's user avatar
  • 8,800
3 votes
3 answers
295 views

Email Validation in PHP

Is this script sufficient enough to validate user email input? ...
user avatar
3 votes
2 answers
667 views

Validator extended to handle domain objects / entities

I started improving my validator library even more, and I think I'm at the last final element (domain object / entity validations) before I can gladly say that my Validator library is completely done ...
Kid Diamond's user avatar
  • 2,591
3 votes
1 answer
3k views

Checking if variable is defined before accessing its properties [closed]

I didn't write this but I noticed it in our codebase at work. ...
stonk-overflow's user avatar
3 votes
1 answer
6k views

Validating individual properties and whole items

I have a custom class I've written which allows me to validate individual properties of items, without firing validation errors on other properties. This allows me to individually validate what my ...
Nick Udell's user avatar
  • 5,197
3 votes
1 answer
3k views

Change password after being validated

I'm doing Python programming challenges and have come across one where the object of the challenge was to create a script to change passwords. The script must validate that the password contains, one ...
YoYoYo I'm Awesome's user avatar