validation

How can I add, remove, or swap jQuery validation rules from a page?

UPDATE: I've come up with a solution to this which I've written as the accepted answer below. Another option is to apply validation rules to all elements initially, add an ".invalid" class to elements you don't want to validate. Swap this class in & out of elements you want to validate as needed. I have a form that toggles what input ...

ASP.NET MVC 2 - Implementing custom Metadata and Validator Providers

With the preview 2 release of ASP.NET MVC 2, we now have base classes to implement our own custom providers for metadata and validation. Specifically, with ModelMetadataProvider and ModelValidatorProvider. There isn't a lot of documentation on these yet (just released yesterday as a preview, so I'm neither surprised nor disappointed). ...

using IDataErrorInfo in asp.net mvc

I've got a simple address entry app that I'm trying to use the IDataErrorInfo interface as explained on the asp.net site. It works great for items that can be validated independantly, but not so well when some items depend on others. For example, validating the postal code depends on the country: private string _PostalCode; pu...

What techniques are being used to pass MVC ModelState validation errors back to the client when using JsonResult?

I'm sort of thinking out loud here, so let me know if I need to clarify... on ajax heavy sites, when using JsonResult to pass information back to the client, what techniques, patterns, best practices are being used to pass ModelState validation errors back to the client? I am using xVal and castle validation on my view models, is there...

Custom Validator on a asp button??

Hi All, I need to place some validation on an asp button to ensure it is clicked at least once. I setup a Custom Validator, set controlToValidate as the button but then found out the Custom Validator can only validate certain controls and a button isn't one of them. I thought about validating an invisible textbox directly next to the ...

Necessary and sufficient validations upon application init

Hello again. I have a new puzzle for you :-). I was thinking on how should an application handle his own start up. Like : checking for required libraries, correct versions, database connectivity, database compatibility, etc. To be specific, here is the test case. I use SWT and Log4J, for obvious reasons. Now, the questions : Should ...

How can I validate US Social Security Number?

Anyone out there know how to improve this function? I'm not worried about shortening the code, I'm sure this could be done with better regex, I am more concerned about correct logic. I have had a terrible time finding documentation for SSN #'s. Most of the rules I use below have come from other programmers who work in the credit indus...

Running a single validation in Rails

Hi, I'm sending friends invitations and I want to validate email address using User.validates_format_of :email, except that User.email has a couple of other validations which I'm not really interested in. So is there a way to run a single validation on a model or check if that specific validation has passed (without doing user.errors...

Determine what controls are failing on a ASP.NET web page

Is there an easy way to determine what controls are failing validation on an ASP.NET web site? I am debugging a page where Page.Validate("group") fails, but I don't know what controls made the page fail. The page is rather big and the code a bit messy, so I am hoping that I could get a list of the IDs of the controls that are failing val...

schema validate xml containing boolean values

Hi I have a xml like this: <xml><fullname> <name attrib="true"/> <lastname1 attrib="false"/> <lastname2 attrib="false"/></fullname></xml> I need to create a schema to validate it in such a way that it will allow only 1 attrib with value "true" (and the rest of them must be false [the attrib attribute is defined to be xs:boolean]), so ...

Rails Complex Form Validations ?

I have a complex form for my Work model. It accepts nested attributes for Credits, Images and Videos. (it is a modified version of Eloy Duran's complex form example) I want to validate presence of at least one Credit I want to validate presence of at least one Image or one Video When I do (in work.rb): validates_presence_of :credits...

How do i validate XML against a schema (php or perl or possible C++)

I need to take in XML and validate it against a schema file. Afterward i must call a function based on the command (example updateContactList). What is the best way to do this? I am worried about validating the XML (and report errors) and i have no idea what is the best way to put the data into a function to run -edit- NOTE: By validati...

How to catch and display warnings to the user.

Essentially the warning in our case is just a validation, we don't want to mark it as an error just a warning so the user knows. I was hoping to use the same or similar method used for validation. Currently I'm leaning towards implementing IDataErrorInfo. But I'd like to change the style on display and allow saving. Has anyone done a...

Validation of interrelated fields

We have a validation system which forces users to select from a valid set of values across a set of inter-related fields. The user has to fill in the first value in the list, and whichever value they have selected determines which set of values they will be able to select from in the second field. Their choice of value in the second fi...

What characters would you make invalid for a password?

A hypothetical situation: you've implemented a password handling system, and it doesn't impose any limitations at all on what characters can be used. You want to set up some rules that are a reasonable compromise between two things - Allow the user as much freedom as possible. Allow for the possibility that you may change how you handl...

Field in mapped entity required

Hi I'm not sure if my problem is solvable in a more or less comfortable way. There is a class Person which has mapped 'hasOne' a participant. The person has a birthday but this field is not required on the person itself. But if I would like to add a participant to the person then the birthday is required. How to get rid of this mo...

Fastest way check xml well formed, and pinpoint problems for Windows Developer

Just wondering if somebody could suggest the quickest tool for the situations where you know somebody committed some invalid XML and you want to find it really fast. Right now I've been using XML Copy Editor. Any other suggestions? I will eventually put validation commit hooks to prevent people from committing invalid .xml files. Tha...

How does one allow a subset of UNICODE codepoints in input validation?

Hello, I am creating a service that could "go international" to non-English speaking markets. I do not want to restrict a username to the ASCII range of characters but would like to allow a user to specify their "natural" username. OK, use UNICODE (and say UTF-8 as my username text encoding). But! I don't want users to create "non-...

How should I handle invalid user input in this case?

I'm writing a plug-in for a geometric modeling program, and I have an abstract class that is based off a Curve object. The curve is only considered valid if it is planar, closed, and does not intersect itself. I then have a chain of other methods that reference this curve that do things like make a surface out of it, or extrude it into...

XML DTD/Schema validation maven plugin

Does anyone knows maven plugin that validate xml documents against DTD or Schema and generates reports? ...