erikgeiser / promptkit

Go prompt library
MIT License
249 stars 21 forks source link

textinput: Validation with error values #7

Closed fiws closed 2 years ago

fiws commented 2 years ago

Hi,

i would like to output a message if the validation failed. The message should help the user to fix the problem, so it should be different depending on the context. Checkout examples/textinput_hidden/main.go in the PR for an (oversimplified) example.

image

I think this is a generic feature that can be useful in promptkit.

I opened this a a draft, cause i don't know if you like the way i implemented this and I only implemented it for text inputs so far.

erikgeiser commented 2 years ago

I'm very sorry for the late reply. I really like the idea and I'll merge this PR with some minor modifications when I find the time.

fiws commented 2 years ago

nice. no worries for the delay. i know that it can be stressful maintaining open source.

You can also tell me the minor modifications you want to see. I might have the time to implement them.

erikgeiser commented 2 years ago

Thank you very much for this great idea and your work with this PR. I made some minor changes, made sure the tests pass (sorry, I had CI misconfigured so it didn't run on your PR) and added docs. I decided that the error value should not be printed by default, though.

Please note that I will not a make a release for this yet because I want to rewrite the library API a bit to use generics and I don't want to relase multiple versions in a short amount of time that all break the API.