Questions tagged [xval]

xVal is a validation framework for ASP.NET MVC applications. It makes it easy to link up your choice of server-side validation mechanism with your choice of client-side validation library, neatly fitting both into ASP.NET MVC architecture and conventions.

Project Description

xVal is a validation framework for ASP.NET MVC applications. It makes it easy to link up your choice of server-side validation mechanism with your choice of client-side validation library, neatly fitting both into ASP.NET MVC architecture and conventions.

Features

Define your validation rules using attributes on model properties, e.g., [Required] [StringLength(50)] public string Name { get; set; } (Or, if you prefer, you can supply rules programmatically or you can just hard-code them in specific views)

  • Designed to fit into ASP.NET MVC conventions for handling form posts and storing and retrieving error information in ModelState
  • Use your choice of server-side validation framework. Out of the box, xVal lets you use .NET 3.5's built-in DataAnnotations classes or Castle Validator (or both). If you want to use something different, you can create your own provider just by implementing IRulesProvider.
  • Use your choice of client-side validation library. Out of the box, xVal lets you use jQuery Validation or ASP.NET's native client-side validation library (a.k.a. WebUIValidation.js, as used by WebForms). Or, use any other client-side validation library by writing a plug-in to configure it using xVal's standard JSON rules description format.
  • Supports localized error messages using resource files. Vary the language of your validation messages according to the current thread's culture.
  • Add custom validation logic that runs both on the server and on the client, either by subclassing an existing rule or by referencing a custom JavaScript function

xVal overview

How to use xVal

For more information, and to see a quick tutorial, see this blog post. Further enhancements are planned To Do.

102 questions
21
votes
1 answer

How to use the jQuery Validation plugin with metadata, jQuery Forms and xVal together?

I've been doing some development using the xVal framework for .NET to link up some of the validation rules for models on the server side along with some client side validation using the jQuery Validation plugin along with the jQuery Form plugin for…
casperOne
  • 73,706
  • 19
  • 184
  • 253
20
votes
6 answers

ASP.NET MVC ValidateInput(false) stops working with xVal and [RegularExpression] DataAnnotation

I would like to intercept the "<" character in the form field by a regex validator. I will describe the problem in 3 steps: Step 1: When I try to submit a form with a field containing the "<" character, I get the "Potentially dangerous request..." -…
Alex42
  • 562
  • 1
  • 5
  • 12
16
votes
3 answers

Asp.Net MVC - Change error class name

When I do field validation in Asp.Net MVC, it's generated the following error css classes : input-validation-error field-validation-error Is there a way that I can change the names of the error classes that are generated? I use xVal.
Melursus
  • 10,328
  • 19
  • 69
  • 103
11
votes
5 answers

Reusing validation attributes in custom ViewModels

When I started using xVal for client-side validation, I was only implementing action methods which used domain model objects as a viewmodel or embedded instances of those objects in the viewmodel. This approach works fine most of the time, but…
Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210
11
votes
4 answers

Which validation library for ASP.NET MVC?

I'm trying to decide what validation approach to take for a new ASP.NET MVC project. (And wow there are plenty of options!) The project uses NHibernate, so the first thing I considered was the NHibernate Validator (Because of tight integration with…
UpTheCreek
  • 31,444
  • 34
  • 152
  • 221
10
votes
4 answers

Validate object based on external factors (ie. data store uniqueness)

Description My solution has these projects: DAL = Modified Entity Framework DTO = Data Transfer objects that are able to validate themselves BL = Business Layer Services WEB = presentation Asp.net MVC application DAL, BL and WEB all reference DTO…
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
9
votes
6 answers

Best practices for input validation in ASP.NET?

What is the common practice of input validation? In other words do you check for input validation on client-side, on server-side or on both sides? Also, if performance is crucial to me, would just the client-side input validation be sufficient for…
Sahat Yalkabov
  • 32,654
  • 43
  • 110
  • 175
8
votes
1 answer

xVal and ASP.Net MVC 2 AddModelStateErrors Problem

I have an application that I've been using xVal successfully on for quite some time. It was recently updated to MVC 2. I use the standard DataAnnotations attributes on my domain models, which also implement a "Validate()" method that calls the…
reallyJim
  • 1,336
  • 2
  • 16
  • 32
6
votes
2 answers

ASP.NET MVC Validation Framework when posting via jquery $.ajax?

There is a plenty of very good post and explanations how to implement validation with ASP.NET MVC, and I prefer one of these: xVal Validation with Service layer Data Annotation attributes However, I really like to call ActionMethods via jquery…
Misha N.
  • 3,455
  • 1
  • 28
  • 36
5
votes
3 answers

C# mvc2 client side form validation with xval, prevent post

I'm using xval to use client side validation in my asp.net mvc2 web-application. Despite the errors it's giving when I enter text in a numeric field, it still tries to post the form to the database. The incorrect values are being replaced by 0 and…
Rob
  • 6,731
  • 12
  • 52
  • 90
5
votes
1 answer

An example of xVal with ASP.NET WebForms?

This is a two part question. Is it possible to take advantage of xVal's automatic client side validation with ASP.NET WebForms? If so, are there any examples available? I imagine that it would be possible to extend xVal to include ASP.NET…
jrummell
  • 42,637
  • 17
  • 112
  • 171
4
votes
3 answers

Auto generating metadata classes for Entity Framework

I am considering using xVal for validation of Entity Framework classes in a MVC application. This involves writing metadata classes as explained in details by Graham O'Neale…
K.A.D.
  • 3,648
  • 3
  • 34
  • 35
4
votes
2 answers

xVal in MVC.NET with nHibernate.validator does not fire client validation

I have an ASP.NET MVC Project working with NHibernate and NHibernate.Validator and i'd like to use xVal 1.0 (most recent release). I Added the requested scripts to the project and referenced it in Site.Master: