copier icon indicating copy to clipboard operation
copier copied to clipboard

Mandatory answer and weird behavior with no default value

Open ppo opened this issue 4 years ago • 2 comments
trafficstars

The documentation says: default: Leave empty to force the user to answer.

When not specifying the default key, the default value is None; perfect.
But the prompt shows 🎤 [None]:.
I think it should be 🎤 : maybe with above that VAR_NAME? Required. Format: str

When pressing enter, it should not accept an empty answer and should ask again (i.e. force the user to enter a value… as mandatory, and as described in the doc)

Currently, if pressing enter, that variable is None and using it in another default value "as a string", if becomes the string"None"… which is a known "problem" with Jinja (or Django templates at least).
Wouldn't it be better to use an empty string "" rather than None (for str variables)?

ppo avatar Feb 12 '21 18:02 ppo

FWIW I think an empty str would be good, in the event that is what the user wants to allow. If an empty str is not valid, in v6.1 the validation will handle that (#398).

drts01 avatar Aug 06 '21 01:08 drts01

I think that the "default" field should not be used to indicate that the answer is required, a field called "required" or "mandatory" should be created, if the "default" field is used then it is equivalent to required=false but an empty string in the default field should not imply required=true since in some cases the default value may be an empty string. Also the "required" field should be true by default.

And if the "validator" field is implemented then it should work together with that field.

eyllanesc avatar Jan 22 '22 05:01 eyllanesc

This issue is leading to very confusing questionnaire behavior. Would it be possible to up the priority? Especially because it is user-facing?

csadorf avatar Sep 27 '22 08:09 csadorf

We have validators now in 6.2. Have you tried with those?

yajo avatar Sep 27 '22 15:09 yajo

We have validators now in 6.2. Have you tried with those?

I had not, thank you for pointing this out. This does constitute a viable work-around for the problem.

csadorf avatar Sep 28 '22 12:09 csadorf