[php-src] Issue #21428: Add FILTER_VALIDATE_STRLEN for UTF-8 string length validation

From: Date: Fri, 13 Mar 2026 02:15:03 +0000
Subject: [php-src] Issue #21428: Add FILTER_VALIDATE_STRLEN for UTF-8 string length validation
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251800@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/21428 Author: masakielastic ### 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. ```php $options = [ 'options' => [ 'max_len' => 2, 'default' => 'error', ], ]; var_dump( filter_var('🐘🐘🐘', FILTER_VALIDATE_STRLEN, $options) ); ```

« previous php.bugs (#251800) next »