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

2
votes
1answer
35 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
54 views

Node2D and Node3D classes implemented using a shared decorator

I have the following classes. validator is a decorator that receives a class which defines validation criteria for a decorated function. ...
7
votes
5answers
349 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 ...
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
545 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
190 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 ...
-1
votes
1answer
30 views
5
votes
1answer
62 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
52 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
581 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
108 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
201 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
314 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
89 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
54 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
128 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
165 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
190 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
775 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
102 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
42 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
98 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
95 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
175 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
37 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
51 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
77 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
179 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
57 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
55 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
68 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
136 views

JavaScript onKeypress validation

This is a function for JavaScript validation: ...
13
votes
3answers
977 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
810 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
107 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
453 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
62 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
521 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
90 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
358 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
149 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. ...