Skip to content

[config] cannotBeEmpty does not work with booleanNode #13736

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy