Description
I would like to propose a new filter validator FILTER_VALIDATE_STRLEN that validates the length of a UTF-8 string.
The length is counted in Unicode code points. Grapheme clusters are not considered.
The validator supports min_len and max_len options and does not depend on the mbstring extension.
A prototype implementation is provided in the accompanying pull request.
$options = [
'options' => [
'max_len' => 2,
'default' => 'error',
],
];
var_dump(
filter_var('🐘🐘🐘', FILTER_VALIDATE_STRLEN, $options)
);
Description
I would like to propose a new filter validator
FILTER_VALIDATE_STRLENthat validates the length of a UTF-8 string.The length is counted in Unicode code points. Grapheme clusters are not considered.
The validator supports
min_lenandmax_lenoptions and does not depend on the mbstring extension.A prototype implementation is provided in the accompanying pull request.