somnambulist-tech / validation

A re-write of rakit/validation, a standalone validation library inspired by Laravel Validation
MIT License
44 stars 13 forks source link

alpha_num ruleTypeError: preg_match(): Argument #2 ($subject) must be of type string, int given #13

Closed jagdtiger9 closed 1 year ago

jagdtiger9 commented 1 year ago
    public function check(mixed $value): bool
    {
        if (!is_string($value) && !is_numeric($value)) {
            return false;
        }

        return preg_match('/^[\pL\pM\pN]+$/u', $value) > 0;
    }

Kind of logical error here If statement allowes string&integer types but preg_match 2-nd param is a string only

dave-redfern commented 1 year ago

@jagdtiger9 thanks for the bug report. It has been fixed in 1.5.5 along with a similar bug in the alpha_dash rule