-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Implementation the new Additional Method nisBR #1880
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dist | ||
node_modules | ||
.idea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
{ | ||
"name": "jquery-validation", | ||
"title": "jQuery Validation Plugin", | ||
"description": "Client-side form validation made easy", | ||
"version": "1.15.2-pre", | ||
"homepage": "http://jqueryvalidation.org/", | ||
"license": "MIT", | ||
"author": { | ||
"name": "Jörn Zaefferer", | ||
"email": "joern.zaefferer@gmail.com", | ||
"url": "http://bassistance.de" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/jzaefferer/jquery-validation.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jzaefferer/jquery-validation/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} | ||
], | ||
"scripts": { | ||
"test": "grunt", | ||
"prepublish": "grunt" | ||
}, | ||
"files": [ | ||
"dist/localization/", | ||
"dist/additional-methods.js", | ||
"dist/jquery.validate.js" | ||
], | ||
"main": "dist/jquery.validate.js", | ||
"dependencies": { | ||
"jquery": "^1.7 || ^2.0" | ||
}, | ||
"devDependencies": { | ||
"commitplease": "2.3.1", | ||
"grunt": "1.0.1", | ||
"grunt-contrib-compress": "1.2.0", | ||
"grunt-contrib-concat": "1.0.1", | ||
"grunt-contrib-copy": "1.0.0", | ||
"grunt-contrib-jshint": "1.0.0", | ||
"grunt-contrib-qunit": "1.2.0", | ||
"grunt-contrib-uglify": "1.0.1", | ||
"grunt-contrib-watch": "1.0.0", | ||
"grunt-jscs": "2.8.0", | ||
"grunt-text-replace": "0.4.0", | ||
"qunitjs": "2.0.0" | ||
}, | ||
"keywords": [ | ||
"jquery", | ||
"jquery-plugin", | ||
"forms", | ||
"validation", | ||
"validate" | ||
] | ||
"name": "jquery-validation", | ||
"title": "jQuery Validation Plugin", | ||
"description": "Client-side form validation made easy", | ||
"version": "1.15.2-pre", | ||
"homepage": "http://jqueryvalidation.org/", | ||
"license": "MIT", | ||
"author": { | ||
"name": "Jörn Zaefferer", | ||
"email": "joern.zaefferer@gmail.com", | ||
"url": "http://bassistance.de" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/jzaefferer/jquery-validation.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jzaefferer/jquery-validation/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} | ||
], | ||
"scripts": { | ||
"test": "grunt", | ||
"prepublish": "grunt" | ||
}, | ||
"files": [ | ||
"dist/localization/", | ||
"dist/additional-methods.js", | ||
"dist/jquery.validate.js" | ||
], | ||
"main": "dist/jquery.validate.js", | ||
"dependencies": { | ||
"jquery": "^1.7 || ^2.0" | ||
}, | ||
"devDependencies": { | ||
"commitplease": "2.3.1", | ||
"grunt": "1.0.1", | ||
"grunt-contrib-compress": "1.2.0", | ||
"grunt-contrib-concat": "1.0.1", | ||
"grunt-contrib-copy": "1.0.0", | ||
"grunt-contrib-jshint": "1.0.0", | ||
"grunt-contrib-qunit": "1.2.0", | ||
"grunt-contrib-uglify": "^2.0.0", | ||
"grunt-contrib-watch": "1.0.0", | ||
"grunt-jscs": "2.8.0", | ||
"grunt-text-replace": "0.4.0", | ||
"qunitjs": "2.0.0" | ||
}, | ||
"keywords": [ | ||
"jquery", | ||
"jquery-plugin", | ||
"forms", | ||
"validation", | ||
"validate" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Created for project jquery-validation. | ||
* @Description Brazillian PIS or NIS number (Número de Identificação Social Pis ou Pasep) is the equivalent of a | ||
* Brazilian tax registration number NIS of PIS numbers have 11 digits in total: 10 numbers followed by 1 check numbers | ||
* that are being used for validation. | ||
* @copyright (c) 25/10/2016 22:40, Cleiton da Silva Mendonça | ||
* @author Cleiton da Silva Mendonça <cleiton.mendonca@gmail.com> | ||
* @link http://gitlab.com/csmendonca Gitlab of Cleiton da Silva Mendonça | ||
* @link http://github.com/csmendonca Github of Cleiton da Silva Mendonça | ||
*/ | ||
|
||
$.validator.addMethod( "nisBR", function( value ) { | ||
|
||
var number; | ||
var cn; | ||
var sum = 0; | ||
var dv; | ||
var count; | ||
var multiplier; | ||
|
||
// Removing special characters from value | ||
value = value.replace( /([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "" ); | ||
|
||
// Checking value to have 11 digits only | ||
if ( value.length !== 11 ) { | ||
return false; | ||
} | ||
|
||
//Get check number of value | ||
cn = parseInt( value.substring( 10, 11 ), 10 ); | ||
|
||
//Get number with 10 digits of the value | ||
number = parseInt( value.substring( 0, 10 ), 10 ); | ||
|
||
for ( count = 2; count < 12; count++ ) { | ||
multiplier = count; | ||
if ( count === 10 ) { | ||
multiplier = 2; | ||
} | ||
if ( count === 11 ) { | ||
multiplier = 3; | ||
} | ||
sum += ( ( number % 10 ) * multiplier ); | ||
number = parseInt( number / 10, 10 ); | ||
} | ||
dv = ( sum % 11 ); | ||
|
||
if ( dv > 1 ) { | ||
dv = ( 11 - dv ); | ||
} else { | ||
dv = 0; | ||
} | ||
|
||
if ( cn === dv ) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}, "Please specify a valid NIS/PIS number" ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess all the changes within this file should not be part of this PR?