-
Notifications
You must be signed in to change notification settings - Fork 632
Description
Information
- OS: Windows
- Version: 0.49.1
- Terminal: Windows Terminal
Describe the bug
TextPrompt.Validate() does not chain with itself. Only the last call to Validate() will run. Any other validators are ignored. This is clear in TextPromptExtensions where obj.Validator is simply replaced each time Validate() is called.
To Reproduce
Chain multiple Validate() calls together. Only the last call will run, regardless of any previous calls.
Expected behavior
If Validate() is used multiple times, each Validator should run. Otherwise, comments should be revised to make it clear that only 1 call to Validate() is allowed.
Additional context
XML comments in TextPromptExtensions indicate that Validate() should chain, and a comment in TextPrompt says "Run all validators". To me, this indicates that multiple validators are allowed and should work as expected.
Multiple Validate() calls would be useful to separate validation logic, and especially to tailor validation errors more specifically. With a single call, multiple checks all have to run at once and the error message must suggest all possible errors.
Semantics are debatable: should validation stop on the first failure, or run all validators and present all failures? Could be configurable.
I am willing to implement this and open a PR if this is a desirable change.
Please upvote 👍 this issue if you are interested in it.