-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add length validators based on the Intl.Segmenter
API
#784
Labels
enhancement
New feature or request
Comments
Thank you for your contribution. We have already discussed this in PR #666 (comment). Feel free to create a PR and copy the source code of |
Fixes: #853 |
This has been implemented and will be available in the next release. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actions
minLength
andmaxLength
useString.prototype.length
, which is not very reliable as it relies on the number of character codes. This approach is not ideal for checking the number of characters the way humans perceive it, especially with emojis. For example, most emojis have a length of 2 (like 🙃), but some have a length of 7 (like 🧑🏻💻).I suggest adding new actions like
minGraphemeCount
ormaxGraphemeCount
, which would use theIntl.Segmenter
API instead ofString.prototype.length
. This would be particularly useful when dealing with user-generated content. As of April 2024, the API is supported in all major browsers.The code would look something like this:
The text was updated successfully, but these errors were encountered: