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 do I access the value to compare when overriding GetClientValidationRules?

I am trying to write a client side validator for angularjs using fluent validation. I used the methods outlined by Darin Dimitrov here. Everything works fine except I can't figure out how to access the greater than value I set up in my validation…
trevorc
  • 3,023
  • 4
  • 31
  • 49
0
votes
0 answers

Multiple form validation in one page MVC 4 with fluent validation

I have a problem like this,In my page I have two forms and each form tag represent different action in controller.what I want to do is I want to have separate validation for each forms.
0
votes
2 answers

Set a text area to required field

I have a textarea which i want to set it to required. I'm trying to use the rulefor from the fluentvalidation but still not happening something. i have try also too to use the [required] etc. Someone can give me a hand with this? Here is my…
user2232273
  • 4,898
  • 15
  • 49
  • 75
0
votes
1 answer

Mocking in Unit Tests

I am trying to test the AddCategory of the following CategoryService. My problem is that I am having a hard time understanding what to mock/fake. My attempt at the test is at the bottom. I am using MOQ, xUnit and FluentAssertions. I am using…
Sam
  • 15,336
  • 25
  • 85
  • 148
0
votes
1 answer

Proper place for validation code in a service?

I am using FluentValidation and a Service Layer for my MVC application. I have a question regarding where you would put logic to check for duplicate items. Say you have a CategoryService and a CategoryValidator, would you put the logic to check for…
Sam
  • 15,336
  • 25
  • 85
  • 148
0
votes
1 answer

fluentvalidation for partial class

I have a customer class like this: [Validator(typeof(CustomerValidator))] public partial class Customer { public string FirstName { get; set; } public string LastName { get; set; } } And my Validation class is: public class…
0
votes
1 answer

Fluent Validation Complex Property message shows Complex Property Name in it

Hi I have class structure like this public class Order { public Address OfficeAddress {get;set;} } public class Address { public string ID {get;set;} public string Street1 {get;set;} public string street2 {get;set;} public string City…
0
votes
1 answer

Validate several properties with conditions used FluentValidation

I have class with DateTime? properties. In general they are pair (request/receive) of dates. I used FluentValidation in my project. Can I write validator which will receive two DateTime? params? Conditions: Request must be less or equal to…
user571874
  • 589
  • 6
  • 25
0
votes
2 answers

automapper showing error "Specified cast is not valid."

i am getting error while mapping DataTable with the model here is my code if (file.ContentLength > 0) { var extension = Path.GetExtension(file.FileName); if (extension != null && extension.ToLower() !=…
rajansoft1
  • 1,336
  • 2
  • 18
  • 38
0
votes
1 answer

Switch ASP.MVC Validation based on Model Instance and Context

For the same MVC controller action and model I would like to have different validation rules applied based on values on the model and based on what user is making the request. For the same Controller and the same Action: If a high level user is…
Joel
  • 1,033
  • 2
  • 12
  • 23
0
votes
2 answers

MVC FluentValidation with entity framework in separate .dll

I have a separate .dll with our database model and partial classes etc in using FluentValidation which works fine (it's to be used by both by desktop barcoding terminals and also by our website). For the desktop apps I can read and display all…
Peter Lea
  • 1,731
  • 2
  • 15
  • 24
0
votes
2 answers

ASP MVC3 FluentValidation on format field

I have a registration page where the user registerer by email. So fot the model I have a validation rule that states: RuleFor(x => x.Email).EmailAddress().WithMessage(localizationService.GetResource("Common.WrongEmail")); The problem now is that I…
Trixz
  • 190
  • 13
0
votes
1 answer

FluentValidation With Autofac

We have just started using FluentValidation and have followed this post to allow us to use our globalized values: http://fluentvalidation.codeplex.com/discussions/394471. However we are stuck on how to get a reference to the interface for the…
user351711
  • 3,171
  • 5
  • 39
  • 74
0
votes
2 answers

Define Generic Type T dynamically at runtime

1. I have a function DoSomeService with object response as parameter. response are different classes the internal code decides which one to use dynamically at runtime. 2. I have a generic Fluent Validator< T> that takes in the type of a response…
Tom
  • 15,781
  • 14
  • 69
  • 111
0
votes
1 answer

How to get a required error message for radio buttons using FluentValidation

I am using ASP.NET MVC 4 and the latest FluentValidation. I am struggling to get my radio buttons to validate. When I click the submit button I need a selection in the radio button list. In my view I have the following: @model…
Brendan Vogt
  • 25,678
  • 37
  • 146
  • 234