Skip to content
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 Japanese mobile phone locale #568

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Passing anything other than a string is an error.
- **isLowercase(str)** - check if the string is lowercase.
- **isMACAddress(str)** - check if the string is a MAC address.
- **isMD5(str)** - check if the string is a MD5 hash.
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-DZ', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-CA', 'en-ZA', 'en-ZM', 'es-ES', 'fi-FI', 'fr-FR', 'hu-HU', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ru-RU', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']`).
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-DZ', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-CA', 'en-ZA', 'en-ZM', 'es-ES', 'fi-FI', 'fr-FR', 'hu-HU', 'ja-JP', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ru-RU', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']`).
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
- **isMultibyte(str)** - check if the string contains one or more multibyte chars.
- **isNull(str)** - check if the string is null (has a length of zero).
Expand Down
1 change: 1 addition & 0 deletions src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const phones = {
'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5)?|50)\s?(\d\s?){4,8}\d$/,
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
'ja-JP': /^(\+?81|0)\d{1,4}[ \-]?\d{1,4}[ \-]?\d{4}$/,
'ms-MY': /^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
'nb-NO': /^(\+?47)?[49]\d{7}$/,
'nn-NO': /^(\+?47)?[49]\d{7}$/,
Expand Down
30 changes: 30 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,36 @@ describe('Validators', function () {
],
args: ['ms-MY'],
});

test({
validator: 'isMobilePhone',
valid: [
'0312345678',
'0721234567',
'09012345688',
'06 1234 5678',
'072 123 4567',
'0729 12 3456',
'07296 1 2345',
'072961 2345',
'090 1234 5678',
'03-1234-5678',
'+81312345678',
'+816-1234-5678',
'+8190-1234-5678',
],
invalid: [
'12345',
'',
'045555717112312332423423421',
'Vml2YW11cyBmZXJtZtesting123',
'+3-585-0555-7171',
'0 1234 5689',
'16 1234 5689',
'03_1234_5689',
],
args: ['ja-JP'],
});
});

it('should validate currency', function () {
Expand Down