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

fix(isAlpha): fix ح character validation in fa-IR language code (#1400) #1455

Merged
merged 3 commits into from
Oct 9, 2020
Merged

fix(isAlpha): fix ح character validation in fa-IR language code (#1400) #1455

merged 3 commits into from
Oct 9, 2020

Conversation

fakhrip
Copy link
Contributor

@fakhrip fakhrip commented Oct 5, 2020

I added some Persian alphabet characters retrieved from wikipedia on this line
Also add new validation regarding the language in the validator.js

This PR specifically fix #1400

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #1455 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1455   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files          96       96           
  Lines        1275     1276    +1     
=======================================
+ Hits         1274     1275    +1     
  Misses          1        1           
Impacted Files Coverage Δ
src/lib/alpha.js 100.00% <100.00%> (ø)
src/lib/isPostalCode.js 100.00% <0.00%> (ø)
src/lib/isMobilePhone.js 100.00% <0.00%> (ø)
src/lib/isPassportNumber.js 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7916dfd...a83805e. Read the comment docs.

@profnandaa
Copy link
Member

Thanks for your contribution! Please rebase your branch with master so as to remove the unrelated changes, then we can review.

@profnandaa profnandaa added the 🧹 needs-update For PRs that need to be updated before landing label Oct 5, 2020
@fakhrip
Copy link
Contributor Author

fakhrip commented Oct 5, 2020

I have removed all unnecessary changes, please tell me if i do something wrong here.

Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contrib 🎉 // Just update the README and we should be good to go.

@fakhrip
Copy link
Contributor Author

fakhrip commented Oct 6, 2020

Im pretty sure that there are nothing to be updated in the readme file regarding these changes as its already well-documented there (in the readme) @profnandaa

Edit: I've checked all the boxes so its all clear

src/lib/alpha.js Outdated
@@ -25,6 +25,7 @@ export const alpha = {
'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
Copy link
Member

Choose a reason for hiding this comment

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

Can move this to L10 so that it's in alphabetic order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing!,
ill do it tonight (got to pray first)

@profnandaa
Copy link
Member

@fakhrip -- my bad, thought it was a new locale.
However, see what you need to fix in L94-103 since it will override what you have added.

@fakhrip
Copy link
Contributor Author

fakhrip commented Oct 6, 2020

@fakhrip -- my bad, thought it was a new locale.
However, see what you need to fix in L94-103 since it will override what you have added.

Im sorry but i didnt get it, in which file should i see this ?

@profnandaa profnandaa removed the 🧹 needs-update For PRs that need to be updated before landing label Oct 7, 2020
@profnandaa
Copy link
Member

That's alpha.js; let me know if there's anything that should be done.

@fakhrip
Copy link
Contributor Author

fakhrip commented Oct 8, 2020

Can we just add this to line 121 in alpha.js to kind of re-override it ?
alpha['fa-IR'] = alpha['fa-IR'];

@profnandaa
Copy link
Member

Ok, that works, you can drop in a comment before that.

@fakhrip
Copy link
Contributor Author

fakhrip commented Oct 9, 2020

Done, if there are anything i should do, please tell me 🙏

@profnandaa profnandaa changed the title feat(isAlpha): feat(isAlpha) fix ح character validation in fa-IR language code (#1400) fix(isAlpha): fix ح character validation in fa-IR language code (#1400) Oct 9, 2020
Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contrib once again! 🎉

@profnandaa profnandaa merged commit 0c55656 into validatorjs:master Oct 9, 2020
@fakhrip
Copy link
Contributor Author

fakhrip commented Oct 10, 2020

Sure, thank you so much for being good as this is my first legit PR 😃

@profnandaa
Copy link
Member

Welcome buddy, looking forward to seeing more from you :)

@tux-tn
Copy link
Member

tux-tn commented Nov 8, 2020

@profnandaa @fakhrip i don't understand the purpose of the change in L124 😅

@fakhrip
Copy link
Contributor Author

fakhrip commented Nov 8, 2020

It was overriden by L101 @tux-tn ,
So there i have to "reoverride" it to set the fa-ir to fa-ir (it may sound confusing though, haha)

@tux-tn
Copy link
Member

tux-tn commented Nov 8, 2020

I still don't get it, since alpha array has already been mutated alpha['fa-ir'] received alpha['fa'] content, how is re-overriding it is supposed to bring back the old content?
Logging content before and after the line shows the same value

@fakhrip
Copy link
Contributor Author

fakhrip commented Nov 8, 2020

export const farsiLocales = [
  'IR', 'AF',
];

for (let locale, i = 0; i < farsiLocales.length; i++) {
  locale = `fa-${farsiLocales[i]}`;
  alpha[locale] = alpha.fa;  // This line changes alpha[fa-IR] content to alpha.fa
  alphanumeric[locale] = alphanumeric.fa;
  decimal[locale] = decimal.fa;
}

And because that the content of alpha.fa and alpha[fa-IR] is different (look below)

'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,

It will then be needed to re-override the alpha[fa-IR] that was changed to alpha.fa, to then become alpha[fa-IR] itself

@tux-tn
Copy link
Member

tux-tn commented Nov 11, 2020

alpha[locale] = alpha.fa; alpha[fa-IR] has been mutated and contains content of alpha.fa here, right?
Since `alpha[fa_IR] has already been mutated where is stored the old value that you need to reassign?

@fakhrip
Copy link
Contributor Author

fakhrip commented Nov 12, 2020

Oh wait, i just realized that i was wrong XD, i'm very sorry dude, now i feel like really stupid...

@fakhrip
Copy link
Contributor Author

fakhrip commented Nov 12, 2020

Do you think i need to fix this in another PR as this one already got merged, or what should i do best ?

@tux-tn
Copy link
Member

tux-tn commented Nov 12, 2020

@fakhrip actually i'm asking the question because i'm working on a PR to update dependencies (including eslint who keeps screaming about that line) i fixed it in my branch and i'll probably create a PR by the end of the week.

@fakhrip
Copy link
Contributor Author

fakhrip commented Nov 13, 2020

@fakhrip actually i'm asking the question because i'm working on a PR to update dependencies (including eslint who keeps screaming about that line) i fixed it in my branch and i'll probably create a PR by the end of the week.

Sure, you're statement is all good, it was my fault, i'm sorry @tux-tn

@tux-tn
Copy link
Member

tux-tn commented Nov 13, 2020

@fakhrip no problem my friend, thank you for taking the time to answer my questions. It's not a big deal

@profnandaa
Copy link
Member

thanks for the due diligence on this @tux-tn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

problem in isAlpha( str ,['fa-IR']) not verify ح character
3 participants