Validation is used to check data to make sure it fits whatever required specifications are set for it.
26
votes
5answers
3k 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 ...
16
votes
5answers
2k 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 ...
16
votes
6answers
5k 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 ...
15
votes
2answers
353 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). ...
12
votes
3answers
171 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 ...
12
votes
3answers
321 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++.
...
11
votes
8answers
1k 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.
...
11
votes
3answers
317 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 ...
11
votes
3answers
456 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, this is purely to show the methods work, rather than unit testing. I ...
10
votes
6answers
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 ...
8
votes
2answers
672 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:
...
7
votes
4answers
1k 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?
...
7
votes
3answers
257 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
4answers
420 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
3answers
234 views
Simple MPG calculator in Python
I am a self taught coder taking a Programming Fundamentals class to work towards a degree. It's based on Python, which I'm not as familiar with as other languages. I added error handling like I would ...
7
votes
2answers
152 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 ...
6
votes
4answers
1k 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 ...
6
votes
2answers
171 views
iOS App - Interface for user log in using a call to a web service API
I have a navigation controller set up with a user code and password and a log in button. When the user clicks on the Log In button or the return key on the keyboard on the password text box - the ...
6
votes
2answers
276 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 ...
6
votes
3answers
414 views
6
votes
3answers
192 views
JS validation and submission with AJAX
I've got an assignment to do pure JS validation as well as submit with AJAX. Here is the code I've got so far. I'm wondering if I can do away with the whole "reason" bit. That was because it was ...
6
votes
2answers
108 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 ...
6
votes
1answer
1k views
Checking input and email field
I've written this as part of my contact form on my website. It checks to see if required inputs are empty, if so adds a red warning color and text. It also checks the email field for a properly ...
6
votes
2answers
154 views
Am I implementing BDD correctly?
I'm writing a utility that validates fields on a web site. I decided I'd give Behaviour Driven Development (BDD) a try. The validator utilises rules to determine if a value the user provided is valid.
...
5
votes
6answers
255 views
Most efficient way to validate multiple textboxes against a tolerance value
I have a series of text boxes in a table to gather input as below:
The user will input a target and actual value for each measurement point they require. I would then like to validate the actual ...
5
votes
2answers
258 views
5
votes
2answers
437 views
Password strength checker
I would like to receive feedback about my code. Is there any better way to shorten the code or is it fine?
Demo
...
5
votes
3answers
106 views
Matching square brackets
I wrote this program to match square brackets as part of a Brainf**k interpreter. I'm aware that it gets caught in an infinite loop if brackets are entered like this: ...
5
votes
1answer
163 views
Validating HTML Form
I am trying to create a simple validation for forms. I am almost there, but there are few bugs and optimization errors that I am really struggling with. I'm looking for advice on how to make this ...
5
votes
1answer
103 views
Date range validator
I have some code which works fine. First, it checks that dates format are valid and then, checks that first date is lower than second date. I had to use free input text and custom validator because ...
5
votes
2answers
373 views
jQuery wrapper of Parsley.js
In a project, I have a lot of HTML forms without validation and I want to add a front end validation, in a quick way. I start looking for a library and I met Parsley.js. It's a good library, but if I ...
5
votes
2answers
87 views
Possible security issues in email validation
I need feedback on this code regarding security issues.
...
5
votes
2answers
164 views
Is this a good object oriented design for a file validator?
I'm working on a module that downloads a file saves it then validates if the file contents are valid.
For simplicity lets assume that the file consists of 3 segments: Header, Body & Footer.
Now ...
5
votes
1answer
98 views
Auto-Format GPA while typing
I'm looking for a more cleaner and simpler solution to auto-format a text-box field intended only for the user to enter their college Grade Point Average (GPA). Here is my code:
...
4
votes
3answers
255 views
32-bit factorial calculator in x86 NASM assembly
This program calculates the factorial of a given positive number.
This is how it handles input:
if negative, terminate program
if 0-2, display input without calculating
if greater than or equal to ...
4
votes
1answer
76 views
Amalgamation of the repository and command / query pattern
I am coding a web based solution which consists of N number of tiers, these are:
UI
Web API
Business
The question I have is related to validation, repository and CRUD operations. I am adopting the ...
4
votes
1answer
495 views
Ajax form validation
This is my first ever attempt at Ajax form validation, and everything works as expected, the final true example will hold a lot more input fields than in my testing scripts which are below.
The file ...
4
votes
0answers
57 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 ...
3
votes
4answers
139 views
Input validation for text boxes in a Form
In a Win Form I'm doing initial validation in the Form. So before saving data, I want to validate whether all the required fields are filled (Text Boxes) by the user. There are about 18 such Text ...
3
votes
4answers
137 views
Dealing with non-required user input
I'm working on a page where a user can create new records, but not all values are required. When creating the SqlCommand with potentially null values, I'm wondering what's the best way, from a code ...
3
votes
2answers
116 views
Client-side validator for contact information form (name, phone, e-mail)
My recent post had some things to fix. I think this should be well structured and written for you.
How does this code look to you? If something needs to be changed please tell me.
...
3
votes
2answers
185 views
Simple structure that would contain validation errors messages
Before I go too far, does this look right?
This is mostly to have a "central" place that hold a "hierarchical/structured" errors message.
...
3
votes
3answers
59 views
Validating a string under few conditions
Following code validates NIC number of a person (National Identity Card, no like SSN)
Requirements are...
Length should be 10 digits or characters
All should be digits except the last one
Last one ...
3
votes
1answer
121 views
ISBN Number Check
I’ve recently coded a way of checking a 10-digit ISBN.
I was wondering if the code works to check the numbers, and if there are any flaws in my code.
...
3
votes
3answers
467 views
Email text validator
I'm using this pattern for the first time and wanted to check if this is the correct implementation.
class.validator.strategy.php
...
3
votes
1answer
81 views
Shortening if-statements of displaying errors
Is it possible to shorten this piece of PHP code?
Honestly, I think it does not look clean but like a mess.
...
3
votes
1answer
131 views
Validating an entity using a dynamic list of predicates
I have a generic extension method for validating my entities. The main idea is to be able to specify at runtime (context related) the criteria for validating a specific entity (with the end goal of ...
3
votes
2answers
195 views
JavaScript form validation: improve on 'good, but not good enough'
I recently received a 'good, but not good enough' rating on a coding exercise I was asked to perform. It was to validate that if "Product complaint" option was selected that Product name, Product ...
3
votes
1answer
54 views
3
votes
1answer
62 views
Class for file creation and directory validation
After reading some texts regarding creation of files under Python, I've decided to create this class which creates a new file on a directory, and creating a backup on the other directory if the file ...