-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
isEmojy added. #1890
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
base: master
Are you sure you want to change the base?
isEmojy added. #1890
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1890 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 102 102
Lines 2072 2072
Branches 472 472
=========================================
Hits 2072 2072 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to add tests
@@ -111,6 +111,7 @@ Validator | Description | |||
**isEAN(str)** | check if the string is an EAN (European Article Number). | |||
**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '', host_blacklist: [] }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part. If `host_blacklist` is set to an array of strings and the part of the email after the `@` symbol matches one of the strings defined in it, the validation fails. | |||
**isEmpty(str [, options])** | check if the string has a length of zero.<br/><br/>`options` is an object which defaults to `{ ignore_whitespace:false }`. | |||
**isEmojy(str)** | check if the string contains any emojis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**isEmojy(str)** | check if the string contains any emojis. | |
**isEmoji(str)** | check if the string contains any emojis. |
@@ -0,0 +1,7 @@ | |||
import assertString from './util/assertString'; | |||
|
|||
export default function isEmojy(str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export default function isEmojy(str) { | |
export default function isEmoji(str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests please. That would ensure fast approval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the file name and validator name, plese rename to isEmoji
Thanks for this, please make the changes suggested and we should land this in. |
|
||
export default function isEmojy(str) { | ||
assertString(str); | ||
const regexExp = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/gi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's broken expression.
It matches Korean character. #1968
one tiny additional issue I see here: What is the intended goal here?
Both of which could be valid use cases, I guess, but in any case expectation and result should match: Currently the validator is called "isEmoji" - and to me this suggests that it tests case b) E.g. EDIT+ |
#1889