validator.js
validator.js copied to clipboard
feat(emoji): add emoji validator
This validator validates single emoji character.
The regex is from https://github.com/mathiasbynens/emoji-regex
I inserted ^ and $ to the start and end of the regex string, and changed the regex flag to i
Checklist
- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)
Codecov Report
Merging #1968 (c3c9408) into master (cfcf911) will not change coverage. The diff coverage is
100.00%.
@@ Coverage Diff @@
## master #1968 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 103 104 +1
Lines 2097 2103 +6
Branches 473 473
=========================================
+ Hits 2097 2103 +6
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/index.js | 100.00% <100.00%> (ø) |
|
| src/lib/isEmoji.js | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update cfcf911...c3c9408. Read the comment docs.
We already have https://github.com/validatorjs/validator.js/pull/1890 almost ready to go, could you review that one to see if you agree with that being merged soon?
@WikiRik Thank you for your kind mention! I've reviewed #1890 and found the expression broken. I hope the isEmoji validator to be merged to validator.js soon!
I just reviewed your test case. Why only a single emoji is allowed? To me, any length of emojis should be validated as a string of emojis.
/^(...emoji regex)+$/