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.
fluentvalidation
1,486 questions
Best practices
0
votes
3
replies
96
views
Optimization of validation of similar properties
I have the following command to create an instance of the domain model:
...
0
votes
2
answers
185
views
Custom error message for failed model binding with FluentValidation
I’m building an ASP.NET Core MVC application with a view model that contains a nullable enum, decimal and other int properties.
Example:
...
0
votes
2
answers
95
views
FluentValidation with ASP.NET Core MVC: DTOs without data annotations still trigger default "is required" messages
I have an ASP.NET Core 9.0 MVC project where I use DTOs for input binding and FluentValidation 12.x for validation.
Entities exist separately and contain data annotations attributes like ...
0
votes
1
answer
39
views
Fluent Validation error not firing due to list for comparison being empty
This a continuation of this question: ASP.NET MVC Create View - Where to place ValidationMessage (Fluent Validation) for a variable
ASP.NET MVC
Firstly, all the validation rules are firing except the ...
0
votes
1
answer
71
views
ASP.NET MVC Create View - Where to place ValidationMessage (Fluent Validation) for a variable
I have this validator class:
...
2
votes
1
answer
70
views
Fluent Validation working in Create but not Edit
Both Create and Edit views use the same validations controller. Create works correctly, showing error messages, and saves upon correcting any validation issues, taking you to the Index view.
For the ...
4
votes
1
answer
214
views
How to make FluentValidation rules optional (skip validation for null/empty strings)?
Validation framework:
...
0
votes
1
answer
84
views
FluentValidation and IRuleBuilder.SetValidator() with dynamic rule sets
Given these models:
public class Foo
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
...
0
votes
1
answer
84
views
FluentValidation unit test with context.RootContextData
I have a unit test that I pass RootContextData, i.e.
...
-1
votes
1
answer
45
views
FluentValidation and IRuleBuilder.SetValidator() with parameters
FluentValidator's .SetValidator() method has an overload that takes params but I can't find any documentation about the use of those params.
...
2
votes
2
answers
88
views
Validate all properties are NOT null if one of the properties is not null
I have a record like this:
...
2
votes
1
answer
65
views
Validation failing when it should pass: .Empty()/.When()
I am trying to understand why my validation test is failing, when I expect it to pass.
Here is the code:
...
0
votes
0
answers
39
views
Fluentvalidation .WithName() and .WithMessage() before or after .When()
Currently i got this code:
...
0
votes
0
answers
26
views
FluentValidator RuleForEach evaluation on a collection should not run next rule for a element if it fails current rule
Suppose I have a class Entity that has a list of strings as controls. I want to make sure each element of the list: 1- Has ...
1
vote
2
answers
179
views
Validating database entity in ASP.NET Core Web API using fluent validation
I'm using fluent validation in my ASP.NET Core Web API. While this works perfectly for scenarios like empty or greater than scenarios, I want to validate database keys / ids.
For example, while adding ...
0
votes
1
answer
126
views
Fluent Validation - Multiple messages for one rule
Is there a way to return multiple messages on one rule?
...
1
vote
1
answer
128
views
Use Fluent Validation to compare values in an array
I have an array of objects I am receiving in an HTTP Post body. Looks something like this:
...
-1
votes
1
answer
102
views
Why I'm not getting 100% code coverage even after completing all the cases?
This is my query class:
...
1
vote
1
answer
170
views
C# Unit testing FluentValidation and mocking nested validator (.SetValidator)
I'm working on a .NET 4.8 project and using FluentValidation v9.5.4. I can't update the version for reasons beyond my control.
Using the example classes from FluentValidation docs:
...
0
votes
0
answers
55
views
Will derived validators using FluentValidation fail if we include a rule set that doesn't exist?
Suppose I have the following domain models in a C# .NET 6 EF Core project:
...
0
votes
1
answer
53
views
Turning off validation on a nested blazor custom control
This is for a .NET 8 blazor webapp.
I have a grid that has an Editor Template as follows:
...
0
votes
1
answer
47
views
'IValidationContext' does not contain a definition for 'CloneForChildValidator'
Im getting this error after i upgrade my fluent Validation package from 8.6.3 to 9.2.2
Could someone please help ?
...
1
vote
1
answer
166
views
How to implement role-based validation using FluentValidation
We have a number of web api services that currently use FluentValidation and SharpGrip.FluentValidation.AutoValidation for ...
1
vote
1
answer
69
views
FluentEditForm says that there is no data, despite data entered being there
My code, below, is a fluenteditform form. After I submit, it says that the fields still need to be filled out even though I filled them out. What is wrong with my code?
...
0
votes
1
answer
548
views
Is it a bad practice to use Fluent Validation with GET request that has body request?
I am attempting to use Fluent Validator in my project. Most of the tutorials that I come so far is using with a post request where you have a json body as a object and that object will be validated by ...
-1
votes
1
answer
63
views
How To register FluentValidation from multiple assemblies
How can i add fluentvalidation which have validation in multiple assemblies.
I have validators also in a shared class Library:
...
0
votes
1
answer
76
views
Error with Fluent validation using Generic
I am trying to create a generic class for fluent validation. Refer the following code.
...
-1
votes
1
answer
150
views
Validate a generic collection using SetValidator in Fluentvalidation
I am trying to validate a generic type:
...
1
vote
1
answer
184
views
Multiple FluentValidator Rules for one Class
I have a single class
public class Foo
{
public string Name { get; set;}
public string Email { get; set;}
public int Id { get; set;}
}
And my objective ...
1
vote
1
answer
81
views
Identifying a specific failed validator for a property with multiple validators
In Fluent Validation, I have multiple validators on a single property, like so:
...
0
votes
1
answer
184
views
IPipelineBehavior ValidationBehavior doesn't get triggered when registered in MediatR
I'm replacing all exception with Result<T> by the LangExt library. The problem is ValidationBehavior doesn't even get ...
0
votes
1
answer
180
views
In-line validation with dynamic components in Blazor/Mudblazor
I am using MudBlazor form components to create a form. The form has some static components and some dynamic components. I am having trouble getting the dynamic components to validate.
Form
...
1
vote
1
answer
407
views
Fluent Validation execute rule depending on multiple other rules
Let's say we have a few validators:
...
1
vote
1
answer
111
views
Fluent validation check to pass only one query parameter from given 2 query parameter
I have get web api where I need to write down fluent validation which we check user can only pass one query parameter.
I have 2 parameters name as action and promo.where parameters types are boolean
...
1
vote
0
answers
75
views
Problem after autocomplete in FluentValidation
If browser autocomplete two field in my register form (email + password) then validator always return true, but form has two others field (confirm password + terms). I can't find solution for this, ...
1
vote
1
answer
933
views
How to Validate Immediately After Leaving Control with Fluent Validation + Blazor Server
I am using Blazor Server, Fluent Validation and Blazored.FluentValidation. I have not really used Fluent Validation for front end for a very long time but I remember when I was using Jquery Validate + ...
0
votes
1
answer
144
views
FluentValidation TestHelper: Handling OverridePropertyName in Unit Tests
Question:
I'm using FluentValidation in my .NET application and have a custom validation method for phone numbers that uses ...
1
vote
0
answers
776
views
Cannot pass null model to Validate. (Parameter 'instanceToValidate')
I need to validate PinCode send from UI, this value need to check with database if not null. I have this code to validate using Fluent Validations:
...
0
votes
0
answers
60
views
Validating only changed properties of a class file with FluentValidation
I have an endpoint that updates (PUTs) an entity. However, the entire class file is not required, only the property the requestor wants to change.
How do I get FluentValidation to just validate the ...
2
votes
1
answer
141
views
ASP.NET Core - How to resolve error in Fluent Validation
I have this code in an ASP.NET Core 8 Web API using Fluent Validation:
...
0
votes
1
answer
104
views
How can I create a RuleSet with a .NET FluentValidation InlineValidator? [2024]
This is an up-to-date version of this question, as the solution no longer applies.
I've implemented fluent validation and am now building tests. The developers of FluentValidations strongly suggest ...
0
votes
0
answers
58
views
Is it possible to get a reference of the input control that got an error in the summary?
I need to have a validation summary with a anchor to the input control that have the error so the user can click on it and get into the input without having to "find" it
the input have ...
1
vote
1
answer
74
views
ASP.NET Core - How to resolve no accessible extension method 'MessageFormatter' Error in Fluent Validation
In ASP.NET Core-8 Web API, I am implementing Custom Messages with Fluent Validation
DTO:
...
2
votes
1
answer
1k
views
FluentValidation uses array index instead of dictionary key when validating dictionary items (Items[0].Name instead of Items["foo"].Name)
Preamble: This is a follow-up to an older question about .NET 4 and ASP.NET 5 with FluentValidation 8.5. While this could be considered a duplicate, enough has changed with FluentValidation over the ...
1
vote
0
answers
210
views
How to validate that byte is greater or equal than specific value using FluentValidation?
I'm using the package FastEndpoints ( which ships FluentValidation ). Given a class defining the request object
...
1
vote
0
answers
104
views
How to trigger fluent validation on change of a dependent property value change?
I have a Boolean property 'AnyLetter' depending on five other Boolean properties. The fluent validation is working when I hit on submit but I would like it trigger like 'Location' property, when value ...
0
votes
0
answers
44
views
ASP.NET Core Null Value Insertion - Ajax Post - Fluent Validation
I am developing an ASP.NET Core project. I am using MSSQL as a database. In my database, there is a Explanation column in my table named Inventory and this column can be left nullable. But I get an ...
0
votes
1
answer
108
views
Set Fluent Validator by condition
I'm trying to set validator for Address depends on item existence, but I wanna use RuleFor and other handy methods rather that manually log every error with ...
0
votes
1
answer
3k
views
FluentValidation is not working in C#/.NET
I'm trying to validate input parameter for my endpoints. I want to use FluentValidator and here is the logic
...
1
vote
0
answers
33
views
Service IValidator Array
My Razor Page project implement CQRS and FluentValidation, every Command or Query needs to be added in the Program.cs class like this:
builder.Services.AddScoped<IValidator < GetPhonesQuery >...