question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate error messages in DataAnnotations attributes

See original GitHub issue

My WebApiConfig looks like this:

public static void Register(HttpConfiguration config){

...

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

FluentValidationModelValidatorProvider.Configure(config);

My controller and model look like this:

public class Model
{
    [Range(0, 2)]
    public int Amount { get; set; }
}

[HttpPost]
public IHttpActionResult Create(Model model)
{
    return Ok(model);
}

When the validation is finished, I end up with two Errors in my ModelState.Values for the Amount property. I have no any other custom validators, just FV enabled. Duplicate error messages also appear when using custom validation in a standard way (inheriting from ValidationAttribute).

Sorry if this issue is duplicated, but I cannot see anything related to it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
JeremySkinnercommented, Apr 12, 2019

I’ve pushed out 8.2.3 with the fix - it should appear in Nuget shortly. Could you give it a try and let me know if it looks ok for you?

Thanks for the help tracking this down.

1reaction
JeremySkinnercommented, Apr 12, 2019

Thanks - I’ll let you know what I find.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicate error messages in DataAnnotations attributes
When the validation is finished, I end up with two Errors in my ModelState.Values for the Amount property. I have no any other...
Read more >
Double error message with remote data annotation mvc 5
hi i am new to MVC and i am trying to use Remote Data annotation with additional fields to validate Name and last...
Read more >
Duplicate Validation Messages with FluentValidation in ASP ...
This means that if you have a model with a property with a type of string, it is expected that the property should...
Read more >
How to avoid double data validation in an application with ...
Validation results in dictionary of error messages with property names as keys, sets flag, but if already set does nothing.
Read more >
Validation with the Data Annotation Validators (C#)
The page in Figure 6 illustrates the error messages returned when you enter invalid values for the Movie properties.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found