Skip to content

Commit

Permalink
2.11.28
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Sep 8, 2017
1 parent a88b02c commit 601c442
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
44 changes: 23 additions & 21 deletions Ui/view/base/web/validator/cpf.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
// 2017-07-12
// https://gist.github.com/cauerego/873308#file-jquery-validate-cpf-js
define(['df', 'Df_Ui/validator'], function(df, v) {
define(['df', 'df-lodash', 'Df_Ui/validator'], function(df, _, validator) {
var f = function(v) {
v = v.replace(/\D/g,'');
/** @type {Boolean} */ var result = true;
/** @type {Number} */ var add = 0;
for (var i = 0; i < 9; i++) {
add += df.int(v.charAt(i)) * (10 - i);
}
var rev = 11 - (add % 11);
if (rev == 10 || rev == 11) {
rev = 0;
}
if (rev !== df.int(v.charAt(9))) {
result = false;
}
else {
add = 0;
for (i = 0; i < 10; i++) {
add += df.int(v.charAt(i)) * (11 - i);
v = _.trim(v);
/** @type {Boolean} */ var result = !/\D/.test(v);
if (result) {
/** @type {Number} */ var add = 0;
for (var i = 0; i < 9; i++) {
add += df.int(v.charAt(i)) * (10 - i);
}
rev = 11 - (add % 11);
var rev = 11 - (add % 11);
if (rev == 10 || rev == 11) {
rev = 0;
}
if (rev != df.int(v.charAt(10))) {
if (rev !== df.int(v.charAt(9))) {
result = false;
}
else {
add = 0;
for (i = 0; i < 10; i++) {
add += df.int(v.charAt(i)) * (11 - i);
}
rev = 11 - (add % 11);
if (rev == 10 || rev == 11) {
rev = 0;
}
if (rev != df.int(v.charAt(10))) {
result = false;
}
}
}
return result;
};
v.add('cpf', f, v.peav('CPF'));
validator.add('cpf', f, validator.peav('CPF'));
});
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/core"
,"version": "2.11.27"
,"version": "2.11.28"
,"description": "Mage2.PRO core package."
,"type": "magento2-module"
,"homepage": "https://mage2.pro"
Expand Down

0 comments on commit 601c442

Please sign in to comment.