validation

Need a regex to validating a Url and support %20 and ()

Hi, I'm currently using the following regular expression to validation URLs: ^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)? (?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|edu|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:...

Validate Uri using a ConfigurationValidator or other validator

In a custom configuration section of a config file I want to have properties or elements define a new scheme, host and port for a service endpoint, but not define the path. So these should be allowed https://newhost/ or http://newhost:800, but not newhost:800, http://newhost/path/to/service. What would be the best option to implement? ...

Where can I find all of the "things" Data Annotation can do (Validation)

Where do they list the attribute (things that you can do with the Data Annotation validation framework). Like, [Required] .... ...

Handing complex validation scenarios in ASP.NET MVC

I'm been working on a GetRuleViolations() method for my User class, but I'm getting a little hung up on on something: What happens when different actions require different business rules? My User table has the following columns: Id, UserRoleId, Username, and Password. Several actions involving User are possible (create new user, edit u...

XML Schema - child elements dependant on existance of optional attribute

Is it possible to define in XSD the following scenario: Parent element has an attribute that is optional. If the attribute is not present in XML, at least one child element must exists. If the attribute is present, there can be zero or more child elements. Example: VALID <parent external-source="some_name" /> <par...

How to stop Eclipse IDE from trying to download DTDs for validation?

I have a XHTML-file using the following doctype-definition: `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;` Eclipse is trying to validate the file by using the referenced dtd file, which results in this error: ParseException: Error validating the model: Se...

RequiredFieldValidator and styling

Hi, Is it possible with the standard .Net field validators to change the style on the textfield, in which the error occures? If I e.g. have a field phonenumber which needs to be filled out, it should create a red border around the textfield on submit, if the field is not filled. Hopefully this can be done with the standard controls so...

NHibernate Validator Dynamic rules

I'm using Nhibernate and I have a requirement that the validation rules must change in time. The framework I'll use is NHibernate validator, but I don't really know how to make dynamic rules, the validation is quite simple with xml files or attributes in the entity class, but the catch is to make this rules updatable. Is there a way to a...

Hibernate validator NotEmpty trim issue

It appears that the Hibernate NotEmpty annotation does not result in an error for strings filled with whitespace (" "). Only works for nulls or empty strings (ie: new String()). Is there a workaround/fix for this? ...

ASP.NET MVC 2 AJAX dilemma: Lose Models concept or create unmanageable JavaScript

Hi, Ok, let's assume we are working with ASP.NET MVC 2 (latest and greatest preview) and we want to create AJAX user interface with jQuery. So what are our real options here? Option 1 - Pass Json from the Controller to the view, and then the view submits Json back to the controller. This means (in the order given): User opens some Vi...

Mapping Validation Attributes From Domain Entity to DTO

Hi, I have a standard Domain Layer entity: public class Product { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set;} } which has some kind of validation attributes applied: public class Product { public int Id { get; set; } [NotEmpty, NotShorterThan10Characters, NotL...

Model binding in ASP.NET MVC when editing an entity

Hi, i am kind of stuck with this code: [AcceptVerbs(HttpVerbs.Post), Authorize] public ActionResult Edit(FormCollection collection, [Bind(Exclude="Id,Latitude,Longitude")]Store bindStore, string Latitude, string Longitude) { Store st = storeModel.GetStore(Session["user_id"].ToString()); bool modelUpdate = Tr...

ASP.NET MVC 1.0 Validation with xVal

I'm actually fine with using another validation method. It seems there aren't many options prebuilt for doing validation with ASP.NET MVC 1.0. The main thing I see people talking about is xVal. However, there is literally no documentation for it. In fact, the blog of the founder seems to only have like two posts on it. Anyway, it's the...

ruby/rails NoMethodError? when using custom validation method

hi all, i'v been new to ruby and rails and encountered a rather strange error: class Person < ActiveRecord::Base validates_presence_of :description, :if => require_description_presence? def require_description_presence? self.can_send_email end end raises NoMethodError in PeopleController#index undefined method ...

Recommended way to make consistent form validation error prompt?

Hi, all. In most web projects, we do both client-side and server-side form validation. A major part of form validation is error prompt, the client-side and server-side form validation library probably have implemented this for us, but the error prompt looks different. How can I design a consistent error prompt for such a system? T...

Good practices for avoiding validation logic duplication when working with both domain objects and view models in ASP.NET MVC

Common scenario: Hierachical domain model is being mapped to flat view model for presentation purposes. I have a full validation setup in my domain and would like to avoid mapping view model to domain object just to find out that some property is invalid. Nor do I want to duplicate my validation logic in my view models. What are so...

Jquery remote validation timeout

I am trying to use jquery validation to validate some input values on the form. On one of the form I have to make a remote call to the server to check if the required entered value is valid or not. So I have something like: $("#myform").validate({ rules: { zip: { required: true, zip: true, remote: "check-zip.action" } } }); N...

How To solve dis synchronize of form Validation?

I am wondering if anyone out there can help with my form Validation Please? I am having a few problems trying to synchronized out how certain bits of the actual structure of the script works together. <?php $flag="OK"; // This is the flag and we set it to OK $msg=""; // Initializing the message to hold the error messages if...

How to consolidate validity checking and exception throwing in Java?

I am implementing an interface which defines a method that can throw an exception if the parameters are not valid. What constitutes valid parameters depends on the implementing class. The interface also defines an isValid() method which can be used to check the parameters but returns a boolean rather than throwing an exception. I have fo...

Doctrine Email Validation triggers on empty form field

Hi, I don't want an empty email field in my form to trigger a Doctrine_Validator_Exception. But, since Doctrine_Validator_Email uses "is_null()" to check for empty (non-existing) values (and the POST ['email'] contains an empty string), it does. Is this correct? Is there a simple way around this? This also has an impact when try...