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

learn more… | top users | synonyms

9
votes
7answers
244 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" ...
4
votes
1answer
51 views

Parsing integers safely

Looking for any feedback. Firstly, correctness, then performance. Background I'm writing user input validation for a client-side JavaScript web application. Users enter numerals representing an ...
5
votes
1answer
56 views

Custom JavaScript validation using the factory / module patterns

I am in the process of diving a bit deeper into JavaScript development and am looking at some common language patterns (module, and factory in particular). In this code, my aim is to create a ...
3
votes
2answers
47 views

Guard statement extension methods for common object guards

I wrote a couple of extension methods for common guard statements I write a lot. These are extension methods for Object, and allow me to quickly guard against common scenarios. I'm using .Net 3.5 ...
6
votes
5answers
566 views

Given a String, return a boolean if it is a number

Yesterday in an online interview, the interviewer asked me this question: If I give you a string, you have to return if a string is number or not. You are not allowed to use any parse function ...
0
votes
0answers
52 views

Check if brackets are balanced [closed]

I'm writing a Python method which checks Python code, given as a string, for errors. One of the things I want it to recognize is mismatched brackets, IE, [} would ...
7
votes
2answers
104 views

Use different contructors of disposable class

I have a very simple helper class to validate credentials. Sometimes the domain has a value, sometimes not. Depending on this, a different constructor for ...
0
votes
0answers
11 views

Reverse Boolean compund logic with NULLs (Change a complex Filter In condition to a Filter Out condition) [closed]

I've been tripping on this one for awhile. The actual logic is even more complex, but simplifying it this far is sufficent. (For those who care, (which does not include the vendor!), the product ...
10
votes
3answers
199 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? ...
8
votes
1answer
305 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 ...
3
votes
1answer
87 views

Automagic (or not quite so) Domain Model Class Validation

The Task I was assigned a small task, concerning validation of Domain-Model classes. The Validation for a String property of one of our Models was required to be unique across the whole Table. And ...
3
votes
1answer
47 views

Form validation evaluation to avoid exploits

Please advise if the form validation script below is secure enough to avoid most types (all types?) of contact form exploits? I ahve found this script online, added some extra php finctions in hope to ...
4
votes
3answers
125 views

Form validation appears to be too rigid

A Stack Overflow coder said my code is too rigid and inflexible. Would someone critique my form validation code, and give some pointers on being more efficient? Code Logic: If the field has an ...
7
votes
3answers
163 views

Validating lines in a file using certain specifications

I have written a program which basically reads a file named "data.txt" line-by-line. As a line is read, it validates the line with a certain specification. If the specification is met, it will ...
6
votes
2answers
189 views

Simple validation script

I'm playing about with JavaScript and wanted to create a simple validation script. It works ok but is a bit clunky. How could I improve it? ...
12
votes
2answers
773 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? ...
4
votes
1answer
82 views

Cron expression validator for Apache Quartz

Not too long ago, I had to create a cron expression for a route in Apache Camel. I had a bit of a struggle to find the right expression. So I made a small program to output the n next valid dates ...
15
votes
7answers
2k 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 ...
3
votes
2answers
41 views

Null checks in user validation

I would like to know an alternative, more elegant way to write the following method. I am especially not enthusiastic of the nested if statement. ...
7
votes
2answers
93 views

JavaScript Validation

Bit of a preface on my motive: I'm self taught and have never really worked in a collaborative environment. My only benchmark for quality is "does it work" and I've never been really subject to peer ...
8
votes
3answers
92 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 ...
4
votes
3answers
174 views

Error-handling / Self-Validating mechanism

The below idea seemed to look clean, to allow the object itself to validate its values for different scenarios. For eg: While creating the object, the value of Object1 and Object2 in ...
5
votes
1answer
134 views

Service class that handles form validations

I've made a (service) class to handle all form validation of my application. It contains a set of frequently used validation callables extracted into private methods that I use to build each ...
2
votes
1answer
32 views

Script for validating a booking form

This PHP script to validates a booking form. (There is also a JavaScript validation as well, but please ignore.). I want to know if there is a better/more efficient way of writing it? I have created ...
0
votes
0answers
49 views

Mini eCommerce Application and Message/Warning/Error Handling

I decided to build a basic eCommerce application in C++ as a learning experience. In the past, I've gone with a fat controller, skinny model approach, and while it has worked, my results always end up ...
2
votes
2answers
74 views

Ruby Mod 11 implementation

I wrote this Ruby Mod 11 (perhaps it's a bit generous to call it that) implementation to validate Brazilian CPF documents, which use a Mod 11 algorithm. CPF format is a 9 digit number followed by two ...
2
votes
1answer
30 views

Form data handler class

I've started to write a form data handler class in PHP. Can you please review it and point out any mistakes or logic errors, or perhaps if a method can be written in a better way? ...
6
votes
1answer
71 views

Agnostic means of identifying a member

I'm attempting to provide an agnostic means of identifying a member. I need a nickname, a guid, and one of ...
6
votes
1answer
89 views

MVC Model validation callback

I have made a simple MVC framework of my own for my personal website to learn a thing or two about how this whole thing even works. I think I've got the idea, but there's one thing I'm not sure about. ...
5
votes
3answers
166 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 ...
1
vote
2answers
39 views

Refactoring complex phone validations

I have a complex phone validation that does the following: First, check if either a home phone, mobile phone or work phone is provided (there will be 3 text fields in form and at least one type of ...
2
votes
1answer
55 views

Redirect browser

I've got a 'menu' within a Master page which include a number of image buttons with click events. Within each click event, I want to redirect the user to a specific page. However, if the user is ...
3
votes
2answers
53 views

Pagination filtering

I want to check if there is page variable (in URL) and if it is, if it's correct - it cannot be number 1 because this is default page and it should be valid int ...
2
votes
2answers
64 views

Validation using preg_match functions

I need some improvements on my code. I did some validation by preg_match and functions. I need some special characters restrictions every field. ...
5
votes
2answers
128 views

JavaScript onKeypress validation

This is a function for JavaScript validation: ...
13
votes
3answers
895 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. ...
14
votes
4answers
806 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 ...
4
votes
3answers
51 views

Validation on a form in JS

I've got a form that needs validating before the data in the form is added to a service queue: ...
0
votes
1answer
97 views

Is this a better way to validate a text box for mobile number only?

Is this a better way to validate a text box for mobile number only? Validation: allow only numbers will not allow to paste string including characters allow copy from the box length is set to 10 ...
10
votes
2answers
426 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 ...
4
votes
1answer
61 views

Using/storing server-side data on the client side

I've a slot booking script which is as follows: My Current Algorithm A calendar is shown to the user The user clicks on a date I make an ajax call to determine if at least 1 slot is booked on the ...
5
votes
1answer
430 views

Bank account number validation in IBAN format

I wrote a JavaScript function for validating bank account numbers in IBAN format. Please tell me how I can make this better. ...
3
votes
2answers
56 views

Simple IPv4 and port validation for chat client

This is part of my chat client's code. It works fine but it looks messy. Any ideas? ...
10
votes
1answer
87 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 ...
10
votes
2answers
334 views

Calculating the checksum digit with the Luhn-algorithm

I'm doing some exercises in Python and this one is about using the Luhn-algorithm to calculate the checksum digit in Swedish personal identification numbers. The description is the same as this ...
3
votes
2answers
126 views

Determining if an entity exists in a database via a stored procedure

Here is a short and simple Ajax method that returns "True" or "False" if an entity exists in a database via a stored procedure ...
12
votes
2answers
141 views

Calculating Luhn-algorithm checksum digit

Today I decided to learn some basic Haskell, and for starters I made a program for calculating the checksum of a Swedish personal identification number. It uses the Luhn-algorithm, aka. ...
2
votes
2answers
118 views

Validate multiple regexes without a for loop in JavaScript

For a project, I need to validate a VAT number against the correct algorithm. I found a library for this here (freeware, so I should be able to reuse it) that I'm grateful exists. However, I feel like ...
7
votes
3answers
206 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 ...