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

learn more… | top users | synonyms

2
votes
1answer
36 views

Sane ranges for DB queries

I have a function that has, as input, a ranges object which may define from, to and ...
2
votes
1answer
54 views

Validating input against rules

I have created a method that validates inputs based on a set of rules. If an error is found, it is put into an array which can later on be used to display the errors to the user. Below is my code: ...
7
votes
3answers
87 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 ...
6
votes
0answers
37 views

C# Multi-checkbox validation MVC4

I wrote the following custom validation annotation for my project to confirm that at least one checkbox of a group of checkboxes is checked: ...
1
vote
1answer
33 views

Refactoring IEnumerable<ValidationResult>

I have the below code which increases the code complexity. Any way to refactor it? I am trying to refactor the below code so that the CCM can be reduced for the code. i.e code complexity matrix. ...
3
votes
1answer
53 views

Test if a string is a number

In need for testing if a string is a number which could be a double or integer, I wrote a simple skeleton, which parses a string like this: ...
3
votes
2answers
56 views

Reservation validation

I got a Reservation model that has reservation_start and reservation_end. Then I have the ...
11
votes
2answers
637 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 ...
3
votes
1answer
53 views

Testable authentication handler for web API

I need to unit test my authentication handler. I don't really want do an assert against the text message returned by the handler. How could this be improved ? ...
1
vote
0answers
43 views

Singleton request validator and sanitizor class

I have tried to code a PHP singleton class for validating multiple/single fields (sanitizing is optional). When validating single field, on success it will return 1 (...
2
votes
0answers
44 views

Immediately send redirect response, preserving session data

This question is for Laravel 4 only, as the relevant parts are completely refactored in the upcoming Laravel 5. I have written an helper function for validation, so I only have to put this in ...
5
votes
2answers
539 views

Should a class own the responsibility of converting an incorrect data type?

The ElectricalEngine class responds to the horsepower message. Because efficiency is calculated in percent a programmer can mistakenly initialize it with an integer ...
3
votes
2answers
287 views

Getting valid URL from user input

I have a dialog which populates my ConnectionStringData object with the URL of the service that I'm trying to connect to. I then consume that URL with the following ...
3
votes
2answers
45 views

Running validation procedures on a table

I am working on a project that has to parse through a text file and perform validations on certain fields in the file. Some of the validations are basic(i.e. data types), and other's are a little more ...
2
votes
2answers
52 views

SPOJ problem: Life, the Universe, and Everything

Your program is to use the brute-force approach in order to find the answer to Life, the Universe, and Everything. More precisely, rewrite small numbers from input to output. Stop processing input ...
10
votes
3answers
111 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 ...
3
votes
2answers
95 views

Outputting Errors to User

I currently am making a small application where a user will enter their ID which needs to be in a certain format. When entered in the wrong format, different output errors are produced. I currently ...
2
votes
1answer
124 views

Validating email addresses and phone numbers

I have following code and I need need help refactoring: Validation class for objects you may create: Email address URL Norwegian Mobile Number (must start with 4, 9 or 59 and be 8 digits long) ...
2
votes
1answer
60 views

Node2D and Node3D classes implemented using a shared decorator

EDIT: I have made another go at this using metaclasses here. I think it's a much better approach. I have the following classes. validator is a decorator that ...
7
votes
5answers
406 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 ...
8
votes
4answers
319 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.... ...
10
votes
5answers
3k 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 ...
12
votes
6answers
680 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" ...
8
votes
2answers
193 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 ...
12
votes
1answer
141 views
+50

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
70 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
670 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 ...
7
votes
2answers
120 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 ...
10
votes
3answers
214 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
394 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
101 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
70 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
135 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
237 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
203 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
785 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
328 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
3k 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
51 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
116 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
109 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
195 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
139 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
135 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 ...
1
vote
0answers
74 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
83 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
40 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
72 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
109 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. ...