Skip to content

[RFC][Validator] empty string validation #35994

Closed
@ro0NL

Description

@ro0NL

This is a more concrete follow up RFC for #28611 + #31528 (https://symfony.com/blog/new-in-symfony-4-4-misc-improvements-part-1#consider-empty-strings-not-valid)

Im still having the "empty string is valid" issue, more or less unexpected for constraints Country and Email, and probably any other "string value validator".

Im pretty much convinced the "emptry string is valid" is an edge case, compared to the common case "an emptry string is not a valid email".

Also, i'd expect to safely pass e.g. ISO codes around with NotNull + Country, not NotBlank + Country.

Solving this issue allows to reduce such constraint lists to simply Country with PHP 74, moving the type responsibility to the code level: public (?)string $country.

I propose to KISS and deprecate empty strings per case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)Validator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions