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.

[Question] FluentValidation and BeginCollectionItem

See original GitHub issue

Anyone know if it is possible to use FluentValidation with BeginCollectionItem which appends GUIDs to the field/property names? I was able to set up the validator:

    RuleForEach(x => x.Insureds).SetValidator(new InsuredInfoValidator());
        
    public class InsuredInfoValidator : AbstractValidator<InsuredInfo>
    {
    	public InsuredInfoValidator()
    	{
    		RuleFor(x => x.LastName).NotEmpty().WithMessage("Required");
    	}
    }

Insureds is my collection. The ModelState validates correctly, but the message does not get placed next to the invalid field: LastName.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Aug 3, 2017

Thanks for the sample. I’ll try and look through this tomorrow.

0reactions
ryanbueningcommented, Aug 7, 2017

@JeremySkinner thanks for looking into it. Do you know if there is a different way I can do model binding to a list and still use FV and have the messages display? From my research, the tricky part happens when you want to delete an index. Maybe this is something that might work?: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/

Read more comments on GitHub >

github_iconTop Results From Across the Web

BeginCollectionItem and FluentValidation
Anyone know if it is possible to use FluentValidation with BeginCollectionItem which appends GUIDs to the field/property names?
Read more >
Fluent Validation for .NET - RSSing.com
Is there a workaround for validating collections that using GUID indices like BeginCollectionItem does? FluentValidation validates the collection of models ...
Read more >
ASP.NET Core — FluentValidation documentation
FluentValidation can be used within ASP.NET Core web applications to validate incoming models. There are two main approaches for doing this:.
Read more >
Using Fluent Validation in ASP.NET Core
Configuring FluentValidation​​ We will have to add Fluent Validation to our application. Navigate to Startup.
Read more >
BeginCollectionItem 1.2.1
This Html Helper leverages the default model binder in ASP.NET MVC 2 and higher to materialize viewmodel collection properties from an HTTP POST ......
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