thebeebs | New X Val Released
thebeebs
Zeroing the desk - Ignore the design
 
 

New X Val Released

by thebeebs 20. September 2009 01:32

xval The new version of xVal is out and it now has dynamic client-side validation summaries and can validate remotely using Ajax. For those that don’t know xVal is a validation engine for MVC that can validate user input not only on the server but also on the client. It means you can write your validation rules once, in one place and you’ll get the benefit throughout your application.

My personal preference for validation is to use data annotations. These are simple annotations that you decorate a class with to instruct frameworks the validation required by each property of your class, xVal reads these annotations and creates the JavaScript required to validate the properties on the client side.

For example the below example stipulates that we must have a title and it must have a certain length, the director and the Box-office total is also required.

using System.ComponentModel.DataAnnotations;

namespace Sample

{
public class Movie

{

public int Id { get; set; }

[Required(ErrorMessage="Movie title is required.")]
[StringLength(8, ErrorMessage="Movie title cannot be longer than 8 characters")]
public string Title { get; set; }

[Required(ErrorMessage="Movie director is required")]
public string Director { get; set; }

[Required(ErrorMessage="Box office totals is required")]
public decimal? BoxOfficeTotals { get; set; }

}
}

I’ll download the xVal demo project today and write up a step by step example. So watch this space.

Tags:

Comments (3) -

rift gold
rift gold United States
3/17/2011 10:30:46 AM #

great blog! keep up the great work!

Reply

buy rift gold
buy rift gold United States
3/25/2011 1:27:22 AM #

Great write-up.  I have certainly enjoyed browsing your blog posts.

Reply

stratford upon avon hotels
stratford upon avon hotels United States
8/14/2011 3:17:01 PM #

Hey this is a great post. Could you keep me updated with any other info similar to this? If travelling to the UK why not stay at Stratford hotel and watch a Shakespear play

Reply

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading