Skip to content

[BUG] min:value and max:value validation rules cause exception #7330

@binaryfire

Description

@binaryfire

I am getting the following exception when using the min: and max: validation rules:

ErrorException (E_DEPRECATED)
str_getcsv(): the $escape parameter must be provided as its default value will change

My system:

Hyperf 3.1.52
PHP 8.4
Ubuntu 24.04

Test controller to reproduce:

<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\Validation\Contract\ValidatorFactoryInterface;

#[Controller(prefix: '/test')]
class ValidationController
{
    #[Inject]
    protected ValidatorFactoryInterface $validatorFactory;

    /**
     * Validation test
     */
    #[RequestMapping(path: "validation", methods: ["GET"])]
    public function testValidation(RequestInterface $request)
    {
        $value = 'test';

        $validator = $this->validatorFactory->make(
            ['value' => $value],
            [
                'value' => [
                    'min:3',
                    'max:64',
                ],
            ],
        );

        if ($validator->fails()) {
            return [
                'success' => false,
                'message' => $validator->errors()->first('name'),
            ];
        }

        return [
            'success' => true,
            'message' => "Validation passed"
        ];
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions