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

Fixed pt-PT alpha and alphanumeric validation #1207

Merged
merged 2 commits into from Dec 6, 2019
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
4 changes: 2 additions & 2 deletions src/lib/alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const alpha = {
'nn-NO': /^[A-ZÆØÅ]+$/i,
'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
'pt-PT': /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,
'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
Copy link
Member

Choose a reason for hiding this comment

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

I will look deeper into the research above. But for now, we can add or edit tests for the addition/changes made on this part.

Copy link
Author

Choose a reason for hiding this comment

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

All right. Since there aren't any tests regarding this locale, I'll write it.

'ru-RU': /^[А-ЯЁ]+$/i,
'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
Expand Down Expand Up @@ -43,7 +43,7 @@ export const alphanumeric = {
'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
'pt-PT': /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,
'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
Copy link
Member

Choose a reason for hiding this comment

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

Apply the comment above on this part.

'ru-RU': /^[0-9А-ЯЁ]+$/i,
'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
Expand Down
40 changes: 40 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,26 @@ describe('Validators', () => {
});
});

it('should validate portuguese alpha strings', () => {
test({
validator: 'isAlpha',
args: ['pt-PT'],
valid: [
'palíndromo',
'órgão',
'qwértyúão',
'àäãcëüïÄÏÜ',
],
invalid: [
'12abc',
'Heiß',
'Øre',
'æøå',
'',
],
});
});

it('should validate italian alpha strings', () => {
test({
validator: 'isAlpha',
Expand Down Expand Up @@ -1466,6 +1486,26 @@ describe('Validators', () => {
});
});

it('should validate portuguese alphanumeric strings', () => {
test({
validator: 'isAlphanumeric',
args: ['pt-PT'],
valid: [
'palíndromo',
'2órgão',
'qwértyúão9',
'àäãcë4üïÄÏÜ',
],
invalid: [
'!abc',
'Heiß',
'Øre',
'æøå',
'',
],
});
});

it('should validate italian alphanumeric strings', () => {
test({
validator: 'isAlphanumeric',
Expand Down