validation

How mature is the Microsoft Code Contracts framework?

Microsoft has recently put a release of their Code Contracts framework on DevLabs with a commercial license. We're interested on using them in our project (mostly C#, some C++/CLI) to gradually replace all the custom validation code, but I'm keen to know about the experience other people have had with it before we commit to it, specifica...

jquery validate on elements not yet created

I'm wondering if it's possible to have the jQuery Validator plugin validate elements that don't yet exist in the dom when the rules are initially setup. Calling the .Rules("add", therules) method only attaches the rules to elements that currently exist in the dom. If I were to create some. The validation doesn't fire. Any thoughts? Hom...

How can I validate a name, middle name, and last name using regex in Java?

I get a list of names and need to validate them. Some examples: Elizabeth T. Bang Elizabeth Bang Zaki M. F. El-Adawy joseph m. pastore, jr. Zaki M. F. El-Adawy How can I use regular expressions in Java to validate them? ...

Options for asp.net MVC Validation Framework

I'm thinking of two options right now for model-base validation for an ASP.net project I'm starting: xVal (Steve Sanderson's project) and the Enterprise module that Stephen Walther uses on this page I don't really know enough to talk about the preferences as I haven't used either of them yet. Any ideas? Update Using LinqToSql for ORM ...

how should we validate http header referrer in aspx .net

I want to ensure ensure nothing untoward gets into the referrer on an error page. What should I be checking in order to validate the http header. below is my current code: // Ensure the referrer header is good if (this.Request.UrlReferrer.IsWellFormedOriginalString() && this.Request.UrlReferrer.Host.Equals(this.Request.Url.Host)) ...

Reuse of validation code in UI, BL and/or DL

I want to have client-side validation for quick response to the user without a roundtrip to the server. I also want the same validation for securing the code behind action on the business and data access layer. How do you reuse that kind of code pragmatically in ASP.NET? (note: ASP.NET, C# 3.0, .NET 3.5, Visual Studio 2008) ...

Hijacking Form Submission on ASP.NET MVC with jQuery (or other)

I'm using ASP.NET MVC (v1.0) on an app and want to integrate simple client-side form validation. IE: Numeric-Only fields, required fields, etc. Is there good, and potentially eye-candy fancy, method of validating in jQuery on the client that will cancel form submission on failed validation? I've perused and experimented with quite a fe...

Equivalent of IllegalArgumentException of Java in C++

In Java if an input argument to a method is invalid, we can throw an IllegalArgumentException (which is of type RuntimeException). In C++, there is no notion of checked and unchecked exceptions. Is there a similar exception in standard C++ which can be used to indicate a runtime exception? Or is there a common style not in the standard b...

Using JQuery Validate Plugin want to alert fields not filled out, but still save

I am using JQuery Validation plugin and have a question about validation. If I have 3 text fields on a form, textboxA, textboxB, and textboxC. I need to make textboxA and textboxB are required to Save, but I want to alert textboxC was not filled in. For example: textboxA and textboxB have data and the form is submitted, an alert to ...

Strange .NET Regex Issue

Given the following RegEx expression, testing this on regexlib.com with the string "2rocks" produces a 'match'. However, in my .NET application, it's causing the regex validator to throw a validation error. ^(?=.*[A-Za-z])[a-zA-Z0-9@\-_\+\.]{6,32}$ If I change the string to "rocks2" in both my application and regexlib.com, I get a mat...

Where should validation logic be implemented?

When developing my interfaces (contracts) and the concrete implementations of them, both the data models as well as repositories, I find myself questioning where the validation logic should go. Part of me (which tends to win out) says that the class itself should be responsible for it's own validation (string max length, date buffers, e...

Validating string lengths based on related database columns

At the one end of my web application I have a database table storing a load of pieces of text. In the middle I have an API that separates my application tiers. At the other end I have a user interface consisting of many TextBoxes (or input type=text form elements, if you prefer). I need the maxlength properties of the TextBoxes to be ...

NHibernate proxies prevent Castle.Validator component to do it's job

Hello, everyone! I've run into the problem with NHibernate proxy validation using Castle.Validator component. It's looks like validator could not fetch attributes from entity proxy's properties. I've tried to define validation attributes using Inherited = true while Castle.Validator runner fetch em using following statement: property....

How can I get my JavaScript, referencing a var defined externally, to validate?

I have an HTML file with a couple of external JavaScript files. Here's an example, somewhat simplified from the real HTML and JavaScript files: <head> <title>Control Page</title> <script language="JavaScript" src="control.js"></script> <script language="JavaScript"> var myWindow; var controlForm; function onPageLoad(...

What are best practices for validating ASP.Net user controls?

I'm wondering if any best practices exist for guidelines as to what should and should not go into a validator control. My thought and practice was that it should be basic sanity checking (i.e. did the user enter all the required inputs? Is there 10 digits in the phone number, is the email address in the valid form? etc..), but I've recen...

Setting up a secure polling system

I'm currently in charge of setting up a polling system (using PHP). Now for it to be as secure and objective as possible, it's important that a visitor can only vote once. I'm thinking of validating the polls by visitor's IP (there can be only one vote from one IP), and maybe throw in a captcha test to be sure that no bots can get in o...

Using Rails validation helpers :message but want it without listing the column name in message

Using Rails validation helpers- validates_xxx_of :the_column, :message => "my message" will generate a validation message : *the_column my message* Is there a way to turn-off the inclusion of the column name? (substitute xxx with any validation helper method) ...

Rails "validates_uniqueness_of" Case Sensitivity

Here is the model (I am using SQLLite3): class School < ActiveRecord::Base validates_uniqueness_of :name end For example, after I add "Yale", I cannot add "Yale" but can add "yale." How can I make the validation case insensitive? EDIT: Found it - Active Record Validations ...

MembershipCreateStatus.InvalidEmail being reached with valid email addresses.

Using the .NET Membership Provider and trying to re-create an Add User page which has been used by other developers (the actual developer has left my company). But while most things work, like editing users, I can't add a new user because this wizard is marking all emails as invalid. I don't know how to update the configuration of the pr...

Spring validation, how to have PropertyEditor generate specific error message

I'm using Spring for form input and validation. The form controller's command contains the model that's being edited. Some of the model's attributes are a custom type. For example, Person's social security number is a custom SSN type. public class Person { public String getName() {...} public void setName(String name) {...} ...