Skip to content

[Console] QuestionHelper: add possibility to ask for a value starting or ending with whitespace #23210

@sustmi

Description

@sustmi
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version all since v2.6 (336bba2)

Currently, QuestionHelper trims all answers (see eg. https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Helper/QuestionHelper.php#L108 ). Can we add a possibility to ask for a value that starts or ends with whitespace?

The actual usecase is for example asking for a password. We do not want to restrict users to use only passwords that do not start or end with whitespace.
PasswordType has this feature by default - see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php#L38 .

The QuestionHelper::doAsk() method is already quite complex but I guess we could add some logic there to check whether Question has flag trimAnswer set or not.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions