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
2 answers

Chainning Rules on Fluent Validation

I'm already using the latest version of Fluent Validation which is 5.4.0.0; What I need to achieve is: Think on a Vehicle VIN, which depends upon Make Id, Model Id and Year of manufacture. Does in Fluent I have the ability to execute a Rule based on…
gandarez
  • 2,609
  • 4
  • 34
  • 47
0
votes
1 answer

FluentValidation MVC Required Foreign Key

I'm creating UserValidator to validate UserViewModel using FluentValidation MVC 5 public class UserValidator : AbstractValidator { public UserValidator() { RuleFor(u => u.UserName) .NotEmpty() …
Willy
  • 1,689
  • 7
  • 36
  • 79
0
votes
2 answers

Validate multiple properties with one rule

Person class class person { public string FirstName { get; set; } public string FatherName { get; set; } public string FamilyName { get; set; } } Each property of this class must be validated with this rule RuleFor(x =>…
0
votes
0 answers

Integrating FluentValidation with MVC 5.1.0.0

I am integrating FluentValidation with MVC 5.1.0.0. and trying to use StructureMap but I got an error when I am compiling the code: Error 5 Assembly 'FluentValidation.Mvc, Version=5.4.0.0, Culture=neutral, PublicKeyToken=null' uses…
Zinov
  • 3,817
  • 5
  • 36
  • 70
0
votes
1 answer

why my Model State is'nt updated when using ajax Post

why my ModelState in controller aren't updated or show true even though there is an error. here is my code $('#extracontent').on('click', '#Save', function () { $.ajax({ type: frm.attr('method'), url: frm.attr('action'), …
kirie
  • 342
  • 2
  • 11
0
votes
1 answer

FluentValidation AbstractValidator<> instances not picked up by NancyFx

I have a NancyFx project that references another project that contains all my FluentValidation AbstractValidator instances. That validation project also references NancyFx.Validation.FluentValidation, however none of the Validators I placed in there…
Jörg Battermann
  • 4,044
  • 5
  • 42
  • 79
0
votes
1 answer

Fluent Validation use of LINQ let?

I'm trying to create a validation rule whereby I can pass in two parameters into a method called by Must() My models; public class Make { public int MakeId { get; set; } public string Name { get; set; } public Car[] Cars { get; set;…
wonea
  • 4,783
  • 17
  • 86
  • 139
0
votes
1 answer

Validating a simple .NET collection is failing when it should pass

I'm trying to create a FluentValidation rule that tests that my IList has to contain 1 or more items. Therefore: It cannot be null It cannot be empty Count > 0 Using FluentValidation, I've setup a rule and then a unit test. The unit test…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
0
votes
3 answers

FluentValidation Rule for MVC DropDownListFor?

I am trying to validate dropdown list using FluentValidation. I think I am doing wrong, but not able to find to solution. I need your help. Model [FluentValidation.Attributes.Validator(typeof (MeetingAbstractValidator))] public class…
James123
  • 11,184
  • 66
  • 189
  • 343
0
votes
1 answer

meta program fluent validation

I have used fluent validation for hard code validations like this: RuleFor(customer => customer.CreditLimit).GreaterThan(customer => customer.MinimumCreditLimit); I guess it would not be a problem to replace MinimumCreditLimit by some (meta)…
cs0815
  • 16,751
  • 45
  • 136
  • 299
0
votes
1 answer

MVC 5 Conditional Validation Option?

I'm developing an MVC 5 web application. Within a particular View I need to validate a ViewModel, however, I need some of the validation only to occur depending on the users inpupt. For example, I have a ViewModel public class TimeEntryViewModel { …
0
votes
2 answers

Remove property name from validation message

Is it possible to remove property name form the validation message? For example, instead of: Field 'Name' should not be empty. I want to show: Field should not be empty. I need to do this global, for all validators.
cryss
  • 4,130
  • 1
  • 29
  • 34
0
votes
1 answer

Validating a list of objects - unobtrusively ASP.NET MVC 3 C#

This seem like it should be easy to implement but I am finding it challenging. I have a list of objects in my view model that need to be validated, unobtrusively. I have looked at FluentValidation for this yet there seems to be a bug in the…
Slinky
  • 5,662
  • 14
  • 76
  • 130
0
votes
1 answer

Using Unity configuration file, how to register FluentValidation Validator Implementation with concrete in a different assembly

I'm trying to register an implementation of FluentValidation.IValidator using a Unity configuration file. The implementation of the Validator is in a referenced assembly. Not sure if this is of importance or not. I have a WCF Host, with 2 references…
0
votes
1 answer

DropDownListFor loses list binding in validation

I am using fluentvalidation and mvc3. I have a drop down list, and it works well. I wanted to test my validation and it works EXCEPT that on validation the drop down list is empty?? What I mean is that if I purposely submit while the default…
GPGVM
  • 5,515
  • 10
  • 56
  • 97