Skip to content
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

Multiple validation errors #314

Closed
TysonMN opened this issue Dec 23, 2020 · 4 comments · Fixed by #315
Closed

Multiple validation errors #314

TysonMN opened this issue Dec 23, 2020 · 4 comments · Fixed by #315

Comments

@TysonMN
Copy link
Member

TysonMN commented Dec 23, 2020

The INotifyDataErrorInfo interface supports multiple errors per property. Elmish.WPF is currently restricting this to a single error (see line 838).

interface INotifyDataErrorInfo with
[<CLIEvent>]
member __.ErrorsChanged = errorsChanged.Publish
member __.HasErrors =
errors.Count > 0
member __.GetErrors propName =
log "[%s] GetErrors %s" propNameChain (propName |> Option.ofObj |> Option.defaultValue "<null>")
match errors.TryGetValue propName with
| true, err -> upcast [err]
| false, _ -> upcast []

The branch demo/multiple_validation_errors contains a proof of concept that shows how to show multiple validation errors in WPF. See the screenshot below. The only hack there is the margin I added to the Submit button so that it wasn't covered by the additional validation errors.

2020-12-23_19-50-09_453

Would anyone like this feature?

I think this feature can be added while remaining backwards compatible, so I think it is fine to exclude this feature from v4.

@cmeeren
Copy link
Member

cmeeren commented Dec 23, 2020

Hm, I think I remember considering this way back. Not sure why I landed the way I did. Are there any built-in or popular 3rd party controls that actually support showing multiple errors?

In any case, I'm not opposed to this.

@TysonMN
Copy link
Member Author

TysonMN commented Dec 24, 2020

Are there any built-in or popular 3rd party controls that actually support showing multiple errors?

Not sure. To repeat for clarity, I was able to display multiple errors without too much trouble. I added a screenshot of that to my previous comment.

Also, I meant to say that I left the tooltip as it was, which is still just showing the first error in the list. That can also be seen in the newly added screenshot.

@BentTranberg
Copy link

Showing multiple errors is very useful. E.g. if a password is too long and is missing certain classes of characters, you want to tell both facts simultaneously.

@TysonMN
Copy link
Member Author

TysonMN commented Dec 30, 2020

I created PR #315 to resolve this issue.

TysonMN pushed a commit to TysonMN/Elmish.WPF that referenced this issue Jan 2, 2021
cmeeren added a commit that referenced this issue Jan 7, 2021
TysonMN added a commit that referenced this issue Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants