8000 [config] cannotBeEmpty does not work with booleanNode · Issue #13736 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[config] cannotBeEmpty does not work with booleanNode #13736
Closed
@jaytaph

Description

@jaytaph

An issue that somebody found:

       $rootNode
            ->children()
                ->booleanNode('use_mock')
                    ->isRequired()
                    ->cannotBeEmpty()
                ->end()

when using: use_mock: false in the config, it will throw a InvalidConfigurationException: The path "config.use_mock" cannot contain an empty value, but got false.

This will be thrown at line:

if (!$this->allowEmptyValue && empty($value)) {
where an empty() check on the boolean false will actually return true.

Is this a bug, or are there other ways to deal with booleanNodes in this situation?

Gist: https://gist.github.com/jaytaph/08906a3f38ca9f0867f8

(Same issue occurs when using a scalarNode() and using "0" as the config value)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0