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

Support german stuff #477

Merged
merged 4 commits into from
Feb 4, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ describe('Validators', function () {
'abc'
, 'ABC'
, 'FoObar'
, 'ÄBC'
, 'FÜübar'
, 'Jön'
]
, invalid: [
'abc1'
Expand All @@ -561,6 +564,9 @@ describe('Validators', function () {
, valid: [
'abc123'
, 'ABC11'
, 'ÄBC'
, 'FÜübar'
, 'Jön'
]
, invalid: [
'abc '
Expand Down Expand Up @@ -1333,6 +1339,22 @@ describe('Validators', function () {
});

it('should validate mobile phone number', function () {
test({
validator: 'isMobilePhone'
, valid: [
'+49 (0) 123 456 789'
, '+49 (0) 123 456789'
, '0123/4567890'
, '+49 01234567890'
, '01234567890'
]
, invalid: [
''
, 'Vml2YW11cyBmZXJtZtesting123'
],
args: ['de-DE']
});

test({
validator: 'isMobilePhone'
, valid: [
Expand Down
7 changes: 4 additions & 3 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
, all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
};

var alpha = /^[A-Z]+$/i
, alphanumeric = /^[0-9A-Z]+$/i
var alpha = /^[A-ZÄÖÜ]+$/i
, alphanumeric = /^[0-9A-ZÄÖÜ]+$/i
, numeric = /^[-+]?[0-9]+$/
, int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/
, float = /^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/
Expand Down Expand Up @@ -99,7 +99,8 @@
'nn-NO': /^(\+?47)?[49]\d{7}$/,
'vi-VN': /^(0|\+?84)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,
'en-NZ': /^(\+?64|0)2\d{7,9}$/,
'en-IN': /^(\+?91|0)?[789]\d{9}$/
'en-IN': /^(\+?91|0)?[789]\d{9}$/,
'de-DE': /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is too verbose. The other mobile phone validators expect that you've stripped non-numeric characters.

};

// from http://goo.gl/0ejHHW
Expand Down