You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to see some method of easy sanitation after an input. I guess I could define a type and require that type for the input but that seems a little extravagant if I want to make sure that say a field entered is a valid email address during input or to strip out spaces automatically. I know I can do this in the code but it should be possible inside prompt.
The text was updated successfully, but these errors were encountered:
Yeah in the code I wrote I ended up just calling strip to sanitize it somewhat and prevent spaces at the beginning and the end but that does not actually validate the data. It does fix the issue I had of people using copy and paste and grabbing a space but not the underlying problem of allowing a complete input sanitization check.
Parameter.callback is already called for the result of prompt (or any other parameter source), but it's called afterprompt returns, not inside it. So while it's possible to perform extra processing, if that processing raises a click.UsageError it exits instead of prompting again.
I'm not sure if this was always the case or if it was due to recent refactors to the type processing pipeline. I think we can extend that refactoring a bit further though to address this issue. prompt is passed self.process_value, which only does type conversion. However, handle_parse_result calls full_process_value (which calls process_value) then applies the callback separately. There's no reason to have that separate anymore, and along with that there's no reason to have both process_value and full_process_value.
Inline Parameter.process_value into Parameter.full_process_value.
Rename full_process_value to process_value.
Move the if self.callback: block from Parameter.handle_parse_result to the bottom of process_value.