Questions tagged [validation]
Validation is used to check data to make sure it fits whatever required specifications are set for it.
728
questions
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?
...
10
votes
6
answers
2k
views
Can people understand my form validation code?
I've just finished creating this form validation but I want to make it public for beginner 'contact us forms'.
I was wondering if I can have some peoples' input on if they can understand/read my ...
10
votes
3
answers
4k
views
"Suspicious comparison of integer references" while checking for a monotonically increasing sequence
I have the following code which iterates on an Integer[] and makes sure that the the values in the array are in ascending order and that there are no neighbouring ...
10
votes
5
answers
896
views
Verifying if a car is a sports car based on speed and horse power
I have an assignment where I am required to verify if a car is a sports car or not by minimum max speed and minimum horse power. I have finished the program and it works great. I was just wanting to ...
10
votes
4
answers
3k
views
Validator for mathematical expression in infix form
This program will validate whether a mathematical expression entered by the user is a valid expression based off whether the expression itself has been entered with the correct scope openers and scope ...
10
votes
3
answers
848
views
Conditionals validation for Tic Tac Toe
I have been working with Java for a little more than a year. I recently have built a Tic Tac Toe game as an assignment for my Java class. After my instructor graded it, he wrote a comment around my ...
10
votes
4
answers
1k
views
Repetitive validation of Console inputs
I have this code that asks the user for inputs and validates the inputs if they are Integers (no other inputs are allowed). I'd like to ask for some help in terms of elegance of the code or ...
10
votes
1
answer
39k
views
Windows filepath and filename validation
I have a Windows program that prompts the user to input a file path and filename. I then check that the file exists with Directory.Exists. Then the user inputs a ...
10
votes
2
answers
16k
views
Checking if a string matches an array of valid characters
I am wondering what a better solution would be for this bit of code:
...
10
votes
2
answers
3k
views
Parsing integers safely
Background
I'm writing user input validation for a client-side JavaScript web application. Users enter numerals representing an integer into an <input>. As ...
10
votes
2
answers
948
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 ...
9
votes
5
answers
6k
views
Python odd number diamond
I worked up a quick diamond program that takes only odd numbers while returning an error with even numbers or 0.
The code looks rather ugly to me, especially with the recurring ...
9
votes
3
answers
24k
views
Validate IP address in Java
Following is the code that I'm currently using to validate the user given IP address (IPV4 and IPV6). It makes use of apache commons-validator's InetAddressValidator...
9
votes
3
answers
222
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 ...
9
votes
4
answers
9k
views
Password Validation in Python
I coded a python solution for the question below. I am after the fastest solution. Also, I would be grateful if you could point out parts that are not pythonic / inefficient.
Question: A website ...
9
votes
3
answers
3k
views
Validation check and code-saving
I have the ubiquitous "validate and save" scenario, wherein the Save() method performs various validity checks and proceeds to save the data. The solution works ...
9
votes
4
answers
421
views
Compact VBA Validator for Excel Names
Update
After examining the NameRulesUnicode64k.xlsm spreadsheet in excel-names, it appears that my NameIsValid() is in close ...
9
votes
2
answers
670
views
Bash script to truncate subject line of incoming email
I'm going to put this script into production in a mail server /etc/aliases file: we have a system that receives email but the subject line must be limited to a certain size. The proposed usage in the ...
9
votes
2
answers
9k
views
Age verification module in Python
I wrote an age verification module in Python 2.5 . How can I improve on current_year? import time perhaps?
...
9
votes
2
answers
57k
views
Restrict HTML input field to decimal
I'd like to restrict user input in a form to a decimal with max two numbers before and 4 after decimal point.
Valid values would be:
50
0.1
1.23
4.5678
12.943
I'...
9
votes
1
answer
5k
views
C function to check the validity of a date in DD.MM.YYYY format [closed]
I was tasked with writing a function, that checks whether a date is valid in the following format: DD.MM.YYYY. Here's what I wrote:
...
8
votes
5
answers
769
views
Checking URL validity
This is sort of a follow up to a previous question (Do I have any SQL leaks?).
I have changed some things around and am working on a solution where I use Active Directory to gather information about ...
8
votes
3
answers
11k
views
Simple Google ReCaptcha validation
Linked:
Google reCAPTCHA Validator: Iteration II
I have also created a simple Google Recaptcha Validation class to handle verification.
I used some code from CodingFusion's post Google New ...
8
votes
3
answers
7k
views
Checking for Roman numeral validity
I am working on a Roman numerals calculator. For an input validity test I'm using this function:
...
8
votes
4
answers
714
views
Simple PHP Validation Routine
I have created a simple validation routine in php and i'm wanting to make sure I am doing things efficiently....
...
8
votes
2
answers
2k
views
Checking some rules before a Telegram bot replies to a message
So far, I've created a couple of programs, and the issue that comes up is how ugly and non-scalable they look.
For example, currently I'm working on a telegram bot. Before replying to a message I ...
8
votes
1
answer
26k
views
Is date 18+ years old?
Considering that:
the passed parameters are all numbers
the passed date is a valid date
It should return:
true if the date is 18 or more years old
...
8
votes
5
answers
4k
views
Validate input that maps int to enum
I've written the following enum and have added a function, fromValue that allows the caller to map given int into the enum value. I was wondering if the ...
8
votes
2
answers
6k
views
Spring password validator library
I recently got rejected at a job interview for submitting this:
https://bitbucket.org/gnerr/password-validator
The interviewer asked for a password validation library that was configurable via ...
8
votes
3
answers
404
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
...
8
votes
3
answers
11k
views
PHP Validation Class
I'm looking for advice and ways on making it better.
Code
...
8
votes
2
answers
345
views
Validating user-provided control points for a Bézier curve
I have made some code which will validate user input for getting 4 control points for a bezier curve. It works fine however I was just wondering If I could make this code any more compact or efficient?...
8
votes
3
answers
363
views
Better card validity check in JS card game
I am writing a card game in Javascript. The game is played with a 32 card deck.
When a card is selected to be played by a user, i do a validity check on the server to check whether it matches the ...
8
votes
2
answers
178
views
Inputting and displaying strings
I have written some code for one of my assignments. However, I feel that I am repeating myself slightly in a few places. I have that niggling feeling that there is a better way to do things.
Here ...
8
votes
3
answers
20k
views
Validation/error handling of user input values
This is a tiny learning program that lead to an interesting question: how can I best/most elegantly handle user entered numbers? This method works, fails cleanly, and reads well. It doesn't apply to ...
8
votes
2
answers
27k
views
Conditional validation on two input fields that depend on each other
My code consists of two input fields and a submit button. The business rules require the following rules:
At least one field must be filled out. Both can be filled out but both cannot be blank.
If ...
8
votes
1
answer
10k
views
Multi-checkbox validation
I wrote the following custom validation annotation for my project to confirm that at least one checkbox of a group of checkboxes is checked:
...
8
votes
1
answer
430
views
Validate an IBAN
I've found an explanation on Wikipedia on how to validate an IBAN. Since the number generated from the transformation can cause overflow with all data types available in VBA, I've worked with ...
8
votes
3
answers
2k
views
Sanitizing and validating a user signup form before submission
The first part of the code (above the in-code comment in the middle) looks messy.
I know I could use variables to make it cleaner, I just don't exactly know yet how can I effectively apply those when ...
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 ...
8
votes
1
answer
7k
views
Validating a credit card
I recently created an extension which detects the type of credit card based on the numbers entered in and formats it. I am using Luhn Algorithm for validating credit card numbers and I am using jQuery ...
8
votes
2
answers
3k
views
Sails.js controller method for an admin to update a user account
I am new to Sails.js, Node.js, and web application development in general. My current understanding is that well-written controllers should be "skinny" meaning they should be as simple as possible, ...
7
votes
3
answers
501
views
Scrubbing user input
I'm taking user input from a file in form (1, 2, 3) to create a color, and I just wanted to know if I was taking most cases into account, and if there is any way I ...
7
votes
3
answers
777
views
Input validation
I am learning C from C Primer Plus, and am still a beginner. I have been introduced to only two functions for input, scanf() and ...
7
votes
4
answers
2k
views
Regex to validate font names
/((([\w -]+)|("[\w -]+"))( *, *)?)+/
http://refiddle.com/18ql
I'm trying to use a PHP regex to sanitize a user input for a list of fonts. The above one seems to ...
7
votes
4
answers
3k
views
Shorter way of prompting for a height of x feet y inches?
I'm currently working on a BMI calculator and just wondered if there was a shorter or more condensed version of doing the if validating statement.
I have currently ...
7
votes
2
answers
2k
views
Validate IP4 address
Validate IP Address
I got this problem during an interview. And would like to get some code review. I also wrote several tests with the expected output, and they all passed as expected.
Validate an ...
7
votes
3
answers
381
views
IP4 strings validator
Trying to write fast non dependency IP4 string validator for embedded system, It should counts leading zeros, values over 255 and other corrupted strings. Not sure if I missed something. Сan you guys ...
7
votes
5
answers
6k
views
Reserving seats in a movie theater
I'm writing a C program to reserve seats in a movie theater. I am validating the selection of seats:
...
7
votes
3
answers
261
views
Refactor a selection validator
I have a data table and have to validate every field in it. I have refactor this code to this below, but the complexity is 15(!!) Should I make something like dictionary with ...