Tagged Questions

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

learn more… | top users | synonyms

5
votes
2answers
533 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
266 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
41 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
47 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
101 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
90 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
85 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
59 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
383 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
295 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
598 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
192 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 ...
8
votes
1answer
97 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
59 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
614 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
116 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
209 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
348 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
93 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
63 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
130 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
170 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
197 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
778 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
194 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
47 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
106 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
97 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
180 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
136 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
62 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
57 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
80 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
31 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
95 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. ...
7
votes
3answers
205 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
45 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
58 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
59 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
92 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
183 views

JavaScript onKeypress validation

This is a function for JavaScript validation: ...
13
votes
3answers
1k 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
821 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
53 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
124 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
567 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
63 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 ...