Add FILTER_VALIDATE_STRLEN for UTF-8 string length validation
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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)
);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the accompanying prototype implementation and the existing filter validator entry points. Check the min_len, max_len, default, UTF-8 code-point counting, and no-mbstring requirements, then verify that the validator handles the example and its boundary cases consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100