Skip to content

Commit

Permalink
Added ukranian locale
Browse files Browse the repository at this point in the history
requested in #584
  • Loading branch information
IOAyman committed Sep 27, 2016
1 parent bccf8a2 commit e15b717
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var alpha = exports.alpha = {
'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[А-ЯЄIЇҐ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
};

Expand All @@ -34,6 +35,7 @@ var alphanumeric = exports.alphanumeric = {
'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[0-9А-ЯЄIЇҐ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
};

Expand Down
2 changes: 2 additions & 0 deletions src/lib/alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const alpha = {
'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[А-ЯЄIЇҐ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
};

Expand All @@ -29,6 +30,7 @@ export const alphanumeric = {
'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[0-9А-ЯЄIЇҐ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
};

Expand Down
34 changes: 34 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,25 @@ describe('Validators', function () {
});
});

it('should validate ukranian alpha strings', function () {
test({
validator: 'isAlpha',
args: ['uk-UA'],
valid: [
'ЯЄIЇҐ',
],
invalid: [
'0AİıÖöÇ窺ĞğÜüZ1',
' AİıÖöÇ窺ĞğÜüZ ',
'abc1',
' foo ',
'',
'ÄBC',
'Heiß',
],
});
});

it('should validate alphanumeric strings', function () {
test({
validator: 'isAlphanumeric',
Expand Down Expand Up @@ -956,6 +975,21 @@ describe('Validators', function () {
});
});

it('should validate urkrainian alphanumeric strings', function () {
test({
validator: 'isAlphanumeric',
args: ['uk-UA'],
valid: [
'ЯЄIЇҐ123',
],
invalid: [
'éeoc ',
'foo!!',
'ÄBC',
],
});
});

it('should error on invalid locale', function () {
try {
validator.isAlphanumeric('abc123', 'in-INVALID');
Expand Down
2 changes: 2 additions & 0 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[А-ЯЄIЇҐ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
};

Expand All @@ -451,6 +452,7 @@
'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[0-9А-ЯЄIЇҐ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
};

Expand Down
Loading

0 comments on commit e15b717

Please sign in to comment.