setAllowEmptyValue example

$node->setNormalizationClosures($this->normalization->before);
        }

        if (isset($this->merge)) {
            $node->setAllowOverwrite($this->merge->allowOverwrite);
        }

        if (true === $this->default) {
            $node->setDefaultValue($this->defaultValue);
        }

        $node->setAllowEmptyValue($this->allowEmptyValue);
        $node->addEquivalentValue(null, $this->nullEquivalent);
        $node->addEquivalentValue(true, $this->trueEquivalent);
        $node->addEquivalentValue(false, $this->falseEquivalent);
        $node->setRequired($this->required);

        if ($this->deprecation) {
            $node->setDeprecated($this->deprecation['package']$this->deprecation['version']$this->deprecation['message']);
        }

        if (isset($this->validation)) {
            $node->setFinalValidationClosures($this->validation->rules);
        }

        $node = new BooleanNode('test');
        $this->assertSame($value$node->normalize($value));
    }

    /** * @dataProvider getValidValues */
    public function testValidNonEmptyValues(bool $value)
    {
        $node = new BooleanNode('test');
        $node->setAllowEmptyValue(false);

        $this->assertSame($value$node->finalize($value));
    }

    public static function getValidValues(): array
    {
        return [
            [false],
            [true],
        ];
    }

    
$node->normalize([]);
    }

    /** * @dataProvider getValidNonEmptyValues * * @param mixed $value */
    public function testValidNonEmptyValues($value)
    {
        $node = new ScalarNode('test');
        $node->setAllowEmptyValue(false);

        $this->assertSame($value$node->finalize($value));
    }

    public static function getValidNonEmptyValues(): array
    {
        return [
            [false],
            [true],
            ['foo'],
            [0],
            [

        $node = new IntegerNode('test');
        $this->assertSame($value$node->normalize($value));
    }

    /** * @dataProvider getValidValues */
    public function testValidNonEmptyValues(int $value)
    {
        $node = new IntegerNode('test');
        $node->setAllowEmptyValue(false);

        $this->assertSame($value$node->finalize($value));
    }

    public static function getValidValues(): array
    {
        return [
            [1798],
            [-678],
            [0],
        ];
    }

        $node = new FloatNode('test');
        $this->assertSame($value$node->normalize($value));
    }

    /** * @dataProvider getValidValues */
    public function testValidNonEmptyValues(int|float $value)
    {
        $node = new FloatNode('test');
        $node->setAllowEmptyValue(false);

        $this->assertSame($value$node->finalize($value));
    }

    public static function getValidValues(): array
    {
        return [
            [1798.0],
            [-678.987],
            [12.56E45],
            [0.0],
            
Home | Imprint | This part of the site doesn't use cookies.