fluentvalidation

How to validate a string as DateTime using FluentValidation

With FluentValidation, is it possible to validate a string as a parseable DateTime without having to specify a Custom() delegate? Ideally, I'd like to say something like the EmailAddress function, e.g.: RuleFor(s => s.EmailAddress).EmailAddress().WithMessage("Invalid email address"); So something like this: RuleFor(s => s.DepartureD...

Using Castle Windsor with FluentValidation In MVC

I'm working on getting FluentValidation working with Castle Windsor. I already have a wrapper around Castle Windsor. Here is the code for that: public class ResolveType { private static IWindsorContainer _windsorContainer; public static void Initialize( IWindsorContainer windsorContainer ) { _windsorCont...

Validate a single property with the Fluent Validation Library for .Net

Can you validate just a single property with the Fluent Validation Library, and if so how? I thought this discussion thread from January of 2009 showed me how to do it via the following syntax: validator.Validate(new Person(), x => x.Surname); Unfortunately it doesn't appear this works in the current version of the library. One other ...

Using FluentValidation with Castle Windsor and Entity Framework 4.0 (POCO) in MVC2

This isn't a very simple question, but hopefully someone has run across it. I am trying to get the following things working together: MVC2 FluentValidation Entity Framework 4.0 (POCO) Castle Windsor I've pretty much gotten everything working. I have Castle Windsor implemented and working with the Controllers being served up by the ...

a basic issue in implementing validations through properties ? Please guide me.

hello, thanks for your attention and time. I want to implement validations in settter of properties. Here is an issue where your expert help is required please. I have idea of how I will do validations before setting value. but not getting what to do if passed value is not correct. Just not setting is not a acceptable solution as I wa...

Using ViewModel in ASP.NET MVC with FluentValidation

I am using ASP.NET MVC with Entity Framework POCO classes and the FluentValidation framework. It is working well, and the validation is happening as it should (as if I were using DataAnnotations). I have even gotten client-side validation working. And I'm pretty pleased with it. Since this is a test application I am writing just to s...

JQuery with Asp.net validation

I have a form that displays an asp.net grid with different people listed in the grid. A user can add new user's to the grid, by clicking an asp.net button on the page: <div id="content_button"> <asp:Button ID="btnAddperson" runat="server" CssClass="content_button" PostBackUrl="addperson.aspx" Text="Add Person" Tool...

Regular Expression Validator does not validate empty textbox

I would like to validate the textbox for specific text and it must not be blank. But the regular expression validator is not validating if the text box is BLANK. However, it validates if I type something in the text box. How can I make regular expression to trigger even if the text box is empty? Should I use Required Validator + ...

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 my website without presenting any security risks? ...

date validation

how we used data validation on asp.net? date can't be insert greater than the current date. ...

How to show errors on in the view from a fluentvalidation result in a asp.net mvc 2 app?

Hello. I am learning asp.net mvc 2 and fluent validation. My setup is shown after the text here. My problem is i do not know how to set the errors contained in the res object on the view page in a nice way. How should this be done? As it is now no errors are displayed on the view, but the validation is working quite well. I suspect i hav...

FluentValidation Validator using arguments

I have a FluentValidation validator that I want to use to validate a booking. On a booking you must choose a room type that exists as an available room type on the tour that you are choosing. I need to get the available room types from a service, passing in the code for the tour. What is the best way to handle getting the tour code where...

Fluent validation: How can i reuse a property validation (projection)

I have a ViewModel which encapsulates a datasource which is a domain object. The domain has validation rules which are defined in the domain, but reused by the ViewModel to provide information to the user. The viewmodel: internal class RatedValuesViewModel : FluentDataErrorInfo { public RatedValuesViewModel() : base(new Rat...

Custom validation attribute with multiple instances problem

I'm using tha namespace System.ComponentModel.DataAnnotations in C# 4 to implement my own validation attribute and it looks like this [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public sealed class MyCustomValidator : ValidationAttribute { private String Property1 { get; set; } private String Property2 { get; ...

Sensible pattern for ValidationError class in C#

I am about to implement a class to represent a validation error. The class would definitely contain a string value called Message, which is a default message to display to a user. I also need a way to represent what the validation error is to the programmer. The idea is that there should be an easy way to determine if a particular valida...

Any .NET Fluent Argument checking libraries out there?

Hi folks, while looking at Shrinkr's source code (we all review other project's source code to learn, right??? :) ) I noticed the following kewl code .. (abbreviated by me, below) public virtual Foo Foo { get; set { Check.Argument.IsNotNull(value, "value"); // then do something. } } Notice the fluen...

Castle Windsor and Fluent Validation as an MVC Validator

I have setup my MVC project to use Fluent Validation and Castle Windsor and everything is working wonderfully. I am using a custom Validator Factory to take into account that I am also using Entity Framework and have to account for the dynamic proxies that get wrapped around my POCO classes. Here is my CastleWindsorValidatorFactory: p...

.net Fluent Validation abstract property SetValidator problem

I have the following code using FluentValidation but it is not possible to call SetValidator(FredAnotherClassValidator()) because it is not of type IAbstractAnotherClass The compiler error is The type 'IAbstractAnotherClass' cannot be used as type parameter 'TCollectionProperty' in the generic type or method 'FluentValidation.DefaultV...

how to represent a list of U.S. States

Trying to do TDD against FluentValidation and Looking for the proper way to represent a list of US States. For example, I have an "Address" object. I would like to write a test (and a FluentValidation rule) that declares the address invalid if it's not in a list of US States. This is a finite list, only to include the 50 US States, ...

FluentValidation or xVal

Hi Guys I am currently reviewing xVal and FluentValidation. I am looking for the following: Ability to keep entities POCO and would prefer not to use attributes/data annotations - I know FluentValidation can do this but have not seen an example of xVal? Ability for jquery/ajax to called validation on the server - I see xVal does this,...