-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make full validation result details available (also per field) #212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @luetm this looks good to me. If you wanted bonus points it would be great to add some tests--it's been on my todo for far too long. 😉
Sure, I'll look into it! |
@luetm : I just had a chance to look at the PR only now and would suggest to store the last FluentValidation's ValidationResult in EditContext instead UI component.
The reason is that EditContext can be used in component-free UI layer like ViewModels. I wouldn't recommend to keep reference to FluentValidator component in a viewmodel. Also lifetime of EditContext might be different than UI Components. I used EditContext like this: class ViewModel
{
public ViewModel()
{
EditContext = new EditContext(this);
//subscribe for EditContext's events, maybe perform initial validation, etc...
}
public EditContext EditContext {get;}
} <EditForm Context="_viewModel.EditContext"> I also recommend you to add option to format different severity levels differently. Without it, the UX will be quite poor. |
@Liero OK, should I do a PR that undoes this PR and implements it in the other way? I like the idea! |
@luetm: Not my choice, I am not even contributor here. I made my own fluentvalidator long time ago, since I needed special features back then, but I'm happy they are being ported here. I'm just sharing my own experience |
@Liero I'm not sure what you mean by this
Can you explain further please? |
Check demo and source code: https://github.com/Liero/vNext.BlazorComponents.FluentValidation
|
It looks like this was once possible (see #75 ). I think the simplest way to add this is to just make the
ValidationFailure
s available, so if anyone needs anything else from it (not just Severity) they can.The approach is easy, I just save the latest validation run for a
FluentValidationValidator
and made a method to easily access it (GetFailuresFromLastValidation
).I tried to follow the style as well as I could, and I added a documentation paragraph about it, which I can remove if that's not desired.
Closes #75