Skip to content

Commit 06d699f

Browse files
Marcholioprofnandaa
authored andcommitted
feat: added finnish locale to isAlpha and isAlphanumeric (#1837)
Co-authored-by: Markus Tyrkkö <[email protected]>
1 parent f821084 commit 06d699f

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ Validator | Description
8585
**contains(str, seed [, options ])** | check if the string contains the seed.<br/><br/>`options` is an object that defaults to `{ ignoreCase: false}`.<br/>`ignoreCase` specified whether the case of the substring be same or not.
8686
**equals(str, comparison)** | check if the string matches the comparison.
8787
**isAfter(str [, date])** | check if the string is a date that's after the specified date (defaults to now).
88-
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
89-
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
88+
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
89+
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
9090
**isAscii(str)** | check if the string contains ASCII chars only.
9191
**isBase32(str)** | check if a string is base32 encoded.
9292
**isBase58(str)** | check if a string is base58 encoded.

src/lib/alpha.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const alpha = {
88
'el-GR': /^[Α-ώ]+$/i,
99
'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
1010
'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
11+
'fi-FI': /^[A-ZÅÄÖ]+$/i,
1112
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
1213
'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
1314
'nb-NO': /^[A-ZÆØÅ]+$/i,
@@ -42,6 +43,7 @@ export const alphanumeric = {
4243
'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
4344
'el-GR': /^[0-9Α-ω]+$/i,
4445
'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
46+
'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
4547
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
4648
'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
4749
'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,

test/validators.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,24 @@ describe('Validators', () => {
14971497
});
14981498
});
14991499

1500+
it('should validate finnish alpha strings', () => {
1501+
test({
1502+
validator: 'isAlpha',
1503+
args: ['fi-FI'],
1504+
valid: [
1505+
'äiti',
1506+
'Öljy',
1507+
'Åke',
1508+
'testÖ',
1509+
],
1510+
invalid: [
1511+
'AİıÖöÇ窺ĞğÜüZ',
1512+
'äöå123',
1513+
'',
1514+
],
1515+
});
1516+
});
1517+
15001518
it('should validate kurdish alpha strings', () => {
15011519
test({
15021520
validator: 'isAlpha',
@@ -1981,6 +1999,24 @@ describe('Validators', () => {
19811999
});
19822000
});
19832001

2002+
it('should validate finnish alphanumeric strings', () => {
2003+
test({
2004+
validator: 'isAlphanumeric',
2005+
args: ['fi-FI'],
2006+
valid: [
2007+
'äiti124',
2008+
'ÖLJY1234',
2009+
'123Åke',
2010+
'451åå23',
2011+
],
2012+
invalid: [
2013+
'AİıÖöÇ窺ĞğÜüZ',
2014+
'foo!!',
2015+
'',
2016+
],
2017+
});
2018+
});
2019+
19842020
it('should validate german alphanumeric strings', () => {
19852021
test({
19862022
validator: 'isAlphanumeric',

0 commit comments

Comments
 (0)