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

Allowing commas in decimal values using Fluent Validation

I am using FluentValidation to validate data in my MVC project. I have a decimal value that I am entering on a page, but if a comma is included in it then validation fails for it. For example "12,000.00". How can I get FluentValidation to accept…
Rono
  • 3,171
  • 2
  • 33
  • 58
0
votes
1 answer

ASP.Net MVC TextBoxFor ignore my format

I create some helper method and create TextBoxFor inside it. input.AppendLine(html.TextBoxFor(expression, format, attributes).ToString()); My format was "{0:dd/MM/yyyy}". It's work totally fine and render as
LLF
  • 668
  • 3
  • 10
  • 27
0
votes
1 answer

Using FluentValidation on a collection that creates partial views not displaying error messages

We are currently using FluentValidation in our MVC project. We needed to be able to create a dynamic view where users could add or remove items. This is accomplished using partialviews.
0
votes
1 answer

How do I force a failed ValidationResult with FluentValidation

I want to check for a null object before validating with FluentValidation. If the object is null I want to force a failed validation result. How do I do that?
pashute
  • 3,965
  • 3
  • 38
  • 65
0
votes
1 answer

How to validate custom dependent validation in fluent validation ? like validate the postal code for different countries

i want the validation like, I have text box and i want to validate the postal code for the country where the site being open. like if i open the site in U.k then when i write postal code in textbox the textbox should validate only U.K postal code…
0
votes
1 answer

How to access propertyvalue in FluentModelValidator

How can I access property value in Fluent Model Validator?. Below is the validator class for ModelA. ModelA has a bool property named isValid. How can I access the boolean value within this class?. public class ModelAValidator : …
user845405
  • 1,461
  • 5
  • 23
  • 43
0
votes
1 answer

Is there a way to completely ignore a property using FluentValidation?

When I try to bind a string ("1,000.00") to a decimal property (x) FluentValidation throws the following error: "The value '1,000.00' is not valid for x." I have a DecimalModelBinder that will handle binding the model but FluentValidation prevents…
Mike
  • 5,437
  • 7
  • 45
  • 62
0
votes
1 answer

how to evaluate lambda expression condition(FluentValidation)

First off, sorry if my title doesn't relate to my question. it has been a long day. Basically, i wanted to know if i can write a class that takes lambda expression and evaluate its condition. IE: (x=>x.property1 == 1) or x=>x.property1 <…
user1784014
  • 234
  • 1
  • 12
0
votes
1 answer

FluentValidation Custom Validation issue

I am having an issue with FluentValidation's Must method. I have this rule in my view model: RuleFor(v => v.StateCd).Must(stateCd => BeAValidStateCode(stateCd)).WithMessage("Please enter a valid, 2 character state code.") …
JB06
  • 1,881
  • 14
  • 28
0
votes
1 answer

Validate an object based on a value using FluentValidation

I have a generic object with particular rules setup in my database. I would like to execute particular rules setup in the database, depending on a value within the object. For example, lets say i have an object like this public class MyObject { …
Gillardo
  • 9,518
  • 18
  • 73
  • 141
0
votes
0 answers

FluentValidation passes an empty string with NotEmpty() when i set an int to empty string

I have this validation code RuleFor(x => x.Name).NotEmpty().WithMessage("[[[Name is required.]]]"); const string sortWeightError = "[[[Sort weight must be a value between 1 and 10000.]]]"; RuleFor(x =>…
Rickard Liljeberg
  • 966
  • 1
  • 12
  • 39
0
votes
1 answer

MVC JQuery unobtrusive validation

How do i override the default error message in unobtrusive validation?. i tried to use $.validator.unobtrusive.messages.dobvalidation to the reset the error message for that validation type but without any success. //DOB Validation …
user845405
  • 1,461
  • 5
  • 23
  • 43
0
votes
1 answer

Wiring up fluentvalidation with Nancy and Ninject

I am using Nancy with Ninject as IoC. All is fine. I now need to add FluentValidation. How do I go about wiring Nancy to use FluentValidation via Ninject? I see there's a NuGet package Ninject.Fluent.Validation but I can't find any documentation or…
Stefano Ricciardi
  • 2,923
  • 3
  • 33
  • 40
0
votes
1 answer

My image validator somehow affects my HttpPostedFileBase value

So I need to validate the image uploads in my application. I'm using some code that I probably got from here and something very weird happens. Firstly, the way my validation works is I use fluent custom validation classes. For the image validation,…
Alternatex
  • 1,505
  • 4
  • 24
  • 47
0
votes
1 answer

Posting form data through Ajax is resulting in Null model data

I'm trying to post my form data which is model bound to a controller via an Ajax request however, the controller is showing that the data is null, despite the request header showing the data is being sent. Code is below. I've tried data:…
Codesight
  • 317
  • 2
  • 14