Skip to content

Length validation does not adhere multibyte chars #97

@jaytaph

Description

@jaytaph

It seems that detecting lengths on strings will use the strlen() function. This causes issues when detecting multibyte strings, as strlen() count bytes, not characters.

Example:

$v->required('user.first_name')->lengthBetween(2, 5)->alpha();
$result = $v->validate([
    'user' => [
        'first_name' => 'Björk',
    ],
]);

will thrown an error on validation, indicating that the length is too long (although bytewise correct, it's doubtful that this would be the expected behaviour)

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