validation

Most Efficient/Elegant Address Validation

I made this small location class so that I can better handle address information which I am going to be sending off in requests to the Google Maps API. One thing I have left to do is some validation to make sure that the address has enough information to return a result back. For the application, the level of accuracy should be as loos...

Where should be the validation in a ASP.Net MVC scenario having Repository, Service Layer and using Model Binder?

Related: What’s the best way to implement field validation using ASP.NET MVC? Let's suppose a solution with the following projects: Foo; // the MVC web project Foo.Models; Foo.Repositories; Foo.Services; Foo.Models is the domain of the application with all the entities, doesn't matter if using EF, NH, POCO or whatever. Here an exampl...

How do I access the value of bound control on a non-displayed tab for validation?

I have created a dialog which contains 3 tabs. Controls on Tabs 1 & 2 have validation using the Validating() event. The user will mainly be working on Tabs 1 & 3, never displaying Tab 2 unless necessary. All controls on Tabs 1 & 2 are bound to a BindingSource object. From my observation, it appears that the bound controls are not ini...

Rails: How to prevent 2 active-record attributes to be equal with validation?

Hi, I want to prevent users from signing up with a password = login for security reasons. I tried something like this: validates_each :password do |record, attr, value| if(value == self.login) record.errors.add(attr) end end But I always get the following error: undefined method login for self. It has something to d...

jQuery validation not working in Thickbox display ajax call

Hello All, Im using Thickbox 3.1 with jQuery 1.3.2 with the Validation plugin and all works great when I run the pages individually but when I use Thickbox the page popup (As it should) but the validation on the page now doesn't work (Inside the Thickbox), any help on this would be great. BTW the strange thing is that Thickbox looks to...

What is the better way/place for validation ?

In my asp.net mvc application i have service layer, which operated with business object, pass its to repository layer and return to controller. No i can't decide where i need to validate object. First place - use data annotation validation with attribute of component model annotation in business objects class, for example: [AcceptVerbs(...

Windows Forms - Validate DataGridView input

I have a Windows Forms application with a DataGridView in one of the forms. The DataGridView can insert and update through a Typed Data Set generated by Visual Studio. I want to show user friendly error messages when a user doesnt fill in a required field or enters the wrong data type, etc. instead of the ugly huge one that is shown by ...

Postfix notation validation?

What would be a good way to evaluate a string(array, something) that contains a postfix expression(ex: 3 5 +) to check for validity? ...

W3C Validating an HTML Page with & in URLs

I have a page in which users submit URLs, some of which contain &, = etc. Now if I want it to validate it with W3C I need to write it as & = etc. How can I automatically do this? Also, should I even bother? ...

Can you use ValidationRules on ListBox.SelectedItems?

I want to use ValidationRules to verify that a few ListBox controls have at least one item selected. I tried doing it this way: <ListBox ItemsSource="{Binding Path=AvailableItems}" Behaviors:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding ChosenItems}" x:Name="ListBoxItems"> <ListBox.Tag> <B...

Custom Validator

Hi I want to use a validator to compare 2 text box in such a way that , If V is in Text box 1, means User must type any of the numbers prefix V in Textbox 2 (V00001 to V00050).Other than V ,if they type any other Letters means error message must be shown. Just like that if C is in TextBox 1 means user must type C00001 in TextBox2.(or...

Designing Javascript validation methods

When doing validation in JavaScript, how do I keep validation methods that need to handle a bunch of contingencies from becoming unruly? For example, I have a form with a field that has validation that checks: is the new value a number? Is the value in another field on the form > 0 when the current field > 0 Is another field on the fo...

validates_presence_of not working properly...how to debug?

In my Review model, I have the following: class Review < ActiveRecord::Base belongs_to :vendor belongs_to :user has_many :votes validates_presence_of :summary end I submit a new entry as follows in the URL: vendors/9/reviews/new The new.html.erb contains a form as follows: <%= error_messages_for 'review' %> <h1>New rev...

Bypass ASP.NET validation for onClick event of input.

I have a <input> with an onclick event which checks for the Enter key. The called function may do a window.location redirect. However, when I press the Enter key, it apparently fires off the page validation. So I see the validation messages for a split second. How can I tell the page not to fire any of the validation events when the ...

How do I create/maintain a valid reference to a particular object in an ActiveRecord association?

Using ActiveRecord, I have an object, Client, that zero or more Users (i.e. via a has_many association). Client also has a 'primary_contact' attribute that can be manually set, but always has to point to one of the associated users. I.e. primary_contact can only be blank if there are no associated users. What's the best way to impleme...

xsd validation againts xsd generated class level validation

In my project I have very big XSD file which i use to validate some XML request and response to a 3rd party. For the above scenario I can have 2 approaches 1) Create XML and then validate against give XSD 2) Create classes from XSD with the help of XSD gen tool, add xtra bit of attirbutes and use them for validation. Validation in the...

Business rules validation in NHibernate Validator

Is it possible to define a validation method (for businbess rules validation) that will be used by NHibernate.Validator? I mean something that exists in EntLib: [HasSelfValidation()] public class SomeClass { //... [SelfValidation()] public virtual void DoValidate(ValidationResults results) { //... } } ...

Field Validation For An IP Address

I am trying to prevent a user from entering anything into a particular textbox aside from a number or a period in C#. The textbox is supposed to contain an IP address. I have it working such that non-numeric entries are prevented, however I can't seem to get it to allow a period to be entered. How might I accomplish this? private vo...

MVC and XVal with drop downs - The value 'Please Select' is invalid.

Im following the approch outlined here to do this. Im having a problem with validating a dropdown selection with xval, the MVC binding seems to infer the wrong thing an allowing the operation to pass validation, but the modelstate stores the binding exception and makes the page invalid - so I get the situation where operation is allowed...

Gridview: Validate that SelectedIndex > -1

I currently have a Gridview, and I want to use client-side validation to ensure that a row has been selected (ie: SelectedIndex > -1). At the moment I'm using <asp:CustomValidator> but want to move away from server-side validation. Here is what I'm currently doing: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="Fa...