Home » Code | ASP.NET | Tools

New X Val Released

19. September 2009 by thebeebs 0 Comments

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.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Add comment

(Will show your Gravatar icon)  

  Country flag

  • Comment
  • Preview