validator.js icon indicating copy to clipboard operation
validator.js copied to clipboard

feat(emoji): add emoji validator

Open HyungJu opened this issue 3 years ago • 3 comments
trafficstars

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)

HyungJu avatar May 16 '22 10:05 HyungJu

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 data Powered by Codecov. Last update cfcf911...c3c9408. Read the comment docs.

codecov[bot] avatar May 16 '22 10:05 codecov[bot]

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 avatar May 17 '22 08:05 WikiRik

@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!

HyungJu avatar May 17 '22 08:05 HyungJu

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)+$/

anasshakil avatar Mar 17 '23 02:03 anasshakil