Questions tagged [fluentvalidation]

Fluent Validation is an ASP.NET MVC integrated validation framework that allows the developer to set validation rules using expressions. It is testable and completely compatible with the inversion of control (dependency injection) pattern and TDD (test-driven development) technique.

Fluent Validation is an open-source, ASP.NET MVC / ASP.NET Core integrated validation framework that allows the developer to set validation rules using expressions. It is testable and completely compatible with the Inversion-of-Control (dependency injection) pattern and TDD (test-driven development) technique.

It is one of a number of validation options, including Data Annotations.

Visit the official website to learn more.

Source code can be found here.

1427 questions
0
votes
1 answer

How to achieve Remote Validation Using Fluent Validation as like Asp.Net MVC Data Annotation Remote validation

Asp.Net MVC provides an internal remote validation by tagging Remote attribute to respective field in your model . When I tag any field with Remote it generates some extra attributes to support Remote validation . data-val-remote="EmailID is…
Deb
  • 391
  • 2
  • 20
0
votes
1 answer

Why is Fluent Validation's IsEmpty rule triggered for my `Id` property that has a value of zero?

I have a view model ApplicantProfileModel that works in all respects. It declares a property [HiddenInput(DisplayValue = false)] public int Id { get; set; } and this property is present in a partial view like this @model…
ProfK
  • 49,207
  • 121
  • 399
  • 775
0
votes
1 answer

Propagate child errors to parent in FluentValidation

Environment: I am using MVC4, Razor 2 and FluentValidation.MVC4 (3.4.6.0). Scenario: I have a complex view model for a particular page which also has a child view model on it as follows: public class ProfileViewModel { public string FirstName…
Mir
  • 2,429
  • 1
  • 29
  • 34
0
votes
2 answers

What must I do to get FluentValidation to display my custom messages?

Right now, it is just displaying a generic 'Initials' should not be empty. message for the following rule: context.RulesFor(p => p.Initials).Required(p => p.Message("Initials are frikking required.")).Length(0, 8); The initials propety is…
ProfK
  • 49,207
  • 121
  • 399
  • 775
0
votes
2 answers

No FluentValidation.Mvc.MetadataExtensions in 3.4.6.0 (avoiding System.Security.VerificationException)

I've inherited some code that uses FluentValidation 3.0.0.1 and on my machine that has .NET 4.5 installed I get the scary System.Security.VerificationException : Operation could destabilize the runtime error. After reading this post:…
user1068352
  • 591
  • 6
  • 14
0
votes
0 answers

Griffin.MvcContrib Localization with FluentValidation

I've been working on my first localization project for mvc and have been using the excellent Griffin.MvcContrib to get me started. I've using the Griffin to handle the language change and the page views, and have a custom provider setup to handle…
TomZomW
  • 531
  • 1
  • 5
  • 15
0
votes
2 answers

How do I retrieve a password with either username OR customerId

All, I am working on an MVC3 c# site. I need the ability for a user to request a new password. The requirement is that they enter either: Their customerId if they know if OR Their chosen username in the one textbox Both are unique in the…
RuSs
  • 1,725
  • 1
  • 29
  • 47
0
votes
1 answer

Fluent validation - group two validators in one custom validator

I have the following validator class: public class FranchiseInfoValidator : AbstractValidator { public FranchiseInfoValidator() { RuleFor(franchiseInfo =>…
Mdb
  • 8,338
  • 22
  • 63
  • 98
0
votes
2 answers

FluentValidation : custom validator factory and client validation

I have my own ValidatorFactory with structuremap implementation in asp net mvc 3 application. public class StructureMapValidatorFactory : ValidatorFactoryBase { public override IValidator CreateInstance(Type validatorType) { …
Mennion
  • 2,873
  • 3
  • 20
  • 34
0
votes
1 answer

Two Validators for one Model

I have this case when I need to validate a model with two validators: 1) a BaseValidator that has some common rules. 2) [Variable]CustomValidator which is determined based on one of the Model's properties. Code that will show you what I…
Dmitry Efimenko
  • 10,973
  • 7
  • 62
  • 79
0
votes
1 answer

Griffin localization and Fluent Validation

I am new to Griffin localization, it seems very cool. However, examples are only showing me how to translate MVC validation attributes. I am using minimum if not none of the mvc validation attributes. My idea is (try) not to validate and report…
Tom
  • 15,781
  • 14
  • 69
  • 111
0
votes
1 answer

Error Message Using FluentValidation in MVC3 app

I am creating an asp.net mvc 3 app in Visual Studio 2010. Im trying to use FluentValidation for my Models. I installed the packages (FluentValidation, FluentValidationMVC3) using NuGet. My Models are as follows (simplified for this forum): public…
0
votes
2 answers

Fluentvalidation - tie validation to specific process best practice

what would be the best practice for tying validation rules to specific process using http://fluentvalidation.codeplex.com/ Currently I'm using "Rule Sets" feature to group rules to different processes: public class ObjAValidation:…
Jernej Gorički
  • 894
  • 1
  • 7
  • 16
0
votes
1 answer

FluentValidation With Lists of Objects

Right now I have a viewmodel that contains three lists of inputs; textboxinput, dropdownlistinput, and checkboxinput. Each of these lists is a list of input objects, which contain four values; paramenums, paramname, paramtype, and value. I am…
Saedeas
  • 1,548
  • 8
  • 17
0
votes
1 answer

How can I validate complex model using FluentValidation and still have access to model?

I have an AccountsViewModel defined as: [Validator(typeof(AccountsValidator))] public class AccountsViewModel { public AccountsViewModel() { Accounts = new List(); Accounts.Add(new Account { AccountNumber =…
Dangerous
  • 4,818
  • 3
  • 33
  • 48