Skip to content

Core: Add sanity checks to dateISO #1528

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
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e1a0f8f
Core: Add sanity checks to dateISO
Jul 18, 2015
7d332af
Core: Add sanity checks to dateISO
Jul 19, 2015
1622e20
Core: Updated regex for dateISO
Jul 20, 2015
299002d
Additionals: Make postalCodeCA method more lenient
thomasgohard Jul 23, 2015
2957a65
Additionals: Correct postalCodeCA to exclude invalid combinations
thomasgohard Jul 23, 2015
bc5efdf
README: Added Gitter badge
gitter-badger Aug 31, 2015
b86e97f
README: Replace pledgie link with 'Looking for maintainers'
jzaefferer Sep 3, 2015
fd68bf7
Core: core.js, methods.js, Fix for #1567 - jquery-validation ignores …
christopherbauer Sep 3, 2015
9e57954
Core: method.js fix tests for #1567
christopherbauer Sep 11, 2015
60e2d83
Core: Validation fails to trigger when next field is already filled out
Arkni Sep 14, 2015
59909c0
Test: Fixed wrong order of parameters of the `equal` method
Arkni Sep 23, 2015
1156d01
Core: escape errorID only for use in the regex
staabm Sep 25, 2015
abc4fb5
Revert "Core: escape errorID only for use in the regex"
staabm Sep 25, 2015
1c162a1
Additional: Fixed spacing issues.
Arkni Sep 19, 2015
834ffb5
Localization: Fixed spacing issues.
Arkni Sep 19, 2015
a401e1d
Core, Ajax: Fixed spacing issues.
Arkni Sep 19, 2015
f124211
Core: Added precondition to call isValidElement method
Arkni Sep 25, 2015
aeca9b5
Demos: Added a new demo using Bootstrap
Arkni Sep 25, 2015
23ae835
Demos: Added a new demo using Semantic UI
Arkni Sep 25, 2015
c0bd1d9
Improving pt_BR translation and fixing a typo on the 'cifES' key.
drovetto Oct 8, 2015
edc4e8f
Test: Added unit test runs into the error reported in #1603
Arkni Oct 9, 2015
04d2888
Core: Escape single quotes in names avoiding a Sizzle Error being thrown
Arkni Oct 9, 2015
500dec8
Test: Added unit test that runs into the issue reported in #1523
Arkni Oct 13, 2015
82be39e
Core: Escape errorID for use in the regex, not to build aria-describedby
Arkni Oct 19, 2015
e0b956c
Build: Adds CommonJS-support in build process. Enhances PR #1597
codeclown Oct 23, 2015
28f56d9
Localisation: Included messages from additional methods
jcspader Aug 17, 2015
07e78db
Add support for contentEditable tags
dorner Feb 26, 2015
d9b228d
Core: Fix lint errors, add test
Feb 27, 2015
da2554b
Core: Fix grunt errors
Mar 2, 2015
0d31925
Core: Fix whitespace
dorner Oct 28, 2015
51563ea
Core: Fix more whitespace
dorner Oct 28, 2015
124672d
Core: Another whitespace fix
dorner Oct 28, 2015
56f3583
Core: Added support for "pending" class on outstanding requests
Jul 24, 2014
0fa7d1e
Tests: uncomment `require_from_group` & `skip_or_fill_minimum` tests
Arkni Oct 30, 2015
a4e959e
Package: Upgrade dev-dependencies to latest versions
Arkni Oct 30, 2015
2eeafaa
Localisation: Update Malay translation
od3n Oct 31, 2015
612b6b7
Aditional: case-insensitive check for BIC
netzkind Aug 12, 2015
a25110e
Tests: new test for Step exception logic added
Nov 11, 2015
c13da41
Core: Extract the file name without including "C:\fakepath\"
Arkni Nov 16, 2015
739939f
Localisation: Updated messages_sk.js
Nov 16, 2015
65359fb
Core: added doc reference to jQuery.validator.methods
staabm Jul 21, 2015
1572de7
Core: Remote validation uses wrong error messages
denisson Mar 4, 2014
4eb997d
Build: fixed bad version constraints
staabm Jan 10, 2016
4c26daa
Core: Required rule take precedence over number & digits rules
Arkni Jan 7, 2016
6f7e48e
Localisation: fixed Persian translation of min/max message.
EsiKhoob Dec 18, 2015
b9da7f1
Localisation: Added missing pattern message in Polish (adamwojtkiewicz)
staabm Jan 28, 2016
d91fc9f
CS: fixed CS issue introduced in da8b6b0
staabm Jan 28, 2016
0271ffb
Localization: added Macedonian localization.
silovski Feb 3, 2016
e3d4ebd
Core: Fixed error when calling .rules() on empty jquery set.
staabm Feb 12, 2016
984fcee
Build: Prepare version 1.15.0
staabm Feb 24, 2016
fcdb0b4
Build: Update release.js
staabm Feb 24, 2016
91a9e0f
Build: Updating the master version to 1.15.1-pre.
staabm Feb 24, 2016
316dc18
Build: removed node regarding patching of jquery-release
staabm Feb 25, 2016
3b3c64c
Build: added docs for upload to NPM
staabm Feb 25, 2016
829ac52
Build: added notes about jsdelivr deployment process
staabm Feb 25, 2016
572d532
Build: added notes about cdnjs deployment process
staabm Feb 25, 2016
cdb77f5
Merge branch 'master' of https://github.com/RobJohnston/jquery-valida…
Mar 15, 2016
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
15 changes: 5 additions & 10 deletions src/additional/accept.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
// Accept a value from a file input based on a required mimetype
$.validator.addMethod( "accept", function( value, element, param ) {

// Split mime on commas in case we have multiple types we can accept
var typeParam = typeof param === "string" ? param.replace( /\s/g, "" ) : "image/*",
var typeParam = typeof param === "string" ? param.replace( /\s/g, "" ).replace( /,/g, "|" ) : "image/*",
optionalValue = this.optional( element ),
i, file, regex;
i, file;

// Element is optional
if ( optionalValue ) {
return optionalValue;
}

if ( $( element ).attr( "type" ) === "file" ) {

// Escape string to be used in the regex
// see: http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
// Escape also "/*" as "/.*" as a wildcard
typeParam = typeParam.replace( /[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g, "\\$&" ).replace( /,/g, "|" ).replace( "\/*", "/.*" );
// If we are using a wildcard, make it regex friendly
typeParam = typeParam.replace( /\*/g, ".*" );

// Check if the element has a FileList before checking each file
if ( element.files && element.files.length ) {
regex = new RegExp( ".?(" + typeParam + ")$", "i" );
for ( i = 0; i < element.files.length; i++ ) {
file = element.files[ i ];

// Grab the mimetype from the loaded file, verify it matches
if ( !file.type.match( regex ) ) {
if ( !file.type.match( new RegExp( "\\.?(" + typeParam + ")$", "i" ) ) ) {
return false;
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/additional/additional.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
( function() {

function stripHtml( value ) {

// Remove html tags and space chars
// remove html tags and space chars
return value.replace( /<.[^<>]*?>/g, " " ).replace( /&nbsp;|&#160;/gi, " " )

// Remove punctuation
// remove punctuation
.replace( /[.(),;:!?%#$'\"_+=\/\-“”’]*/g, "" );
}

Expand Down
5 changes: 2 additions & 3 deletions src/additional/bankaccountNL.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ $.validator.addMethod( "bankaccountNL", function( value, element ) {
if ( !( /^[0-9]{9}|([0-9]{2} ){3}[0-9]{3}$/.test( value ) ) ) {
return false;
}

// Now '11 check'
var account = value.replace( / /g, "" ), // Remove spaces
// now '11 check'
var account = value.replace( / /g, "" ), // remove spaces
sum = 0,
len = account.length,
pos, factor, digit;
Expand Down
4 changes: 2 additions & 2 deletions src/additional/bic.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* - Next 2 characters - ISO 3166-1 alpha-2 country code (only letters)
* - Next 2 characters - location code (letters and digits)
* a. shall not start with '0' or '1'
* b. second character must be a letter ('O' is not allowed) or digit ('0' for test (therefore not allowed), '1' denoting passive participant, '2' typically reverse-billing)
* b. second character must be a letter ('O' is not allowed) or one of the following digits ('0' for test (therefore not allowed), '1' for passive participant and '2' for active participant)
* - Last 3 characters - branch code, optional (shall not start with 'X' except in case of 'XXX' for primary office) (letters and digits)
*/
$.validator.addMethod( "bic", function( value, element ) {
return this.optional( element ) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-9])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( value.toUpperCase() );
return this.optional( element ) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( value.toUpperCase() );
}, "Please specify a valid BIC code" );
3 changes: 1 addition & 2 deletions src/additional/cpfBR.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* CPF numbers have 11 digits in total: 9 numbers followed by 2 check numbers that are being used for validation.
*/
$.validator.addMethod( "cpfBR", function( value ) {

// Removing special characters from value
value = value.replace( /([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "" );

Expand All @@ -27,7 +26,7 @@ $.validator.addMethod( "cpfBR", function( value ) {
};

// Checking for dump data
if ( value === "" ||
if (value === "" ||
value === "00000000000" ||
value === "11111111111" ||
value === "22222222222" ||
Expand Down
18 changes: 9 additions & 9 deletions src/additional/creditcardtypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,31 @@ $.validator.addMethod( "creditcardtypes", function( value, element, param ) {
if ( param.all ) {
validTypes = 0x0001 | 0x0002 | 0x0004 | 0x0008 | 0x0010 | 0x0020 | 0x0040 | 0x0080;
}
if ( validTypes & 0x0001 && /^(5[12345])/.test( value ) ) { // Mastercard
if ( validTypes & 0x0001 && /^(5[12345])/.test( value ) ) { //mastercard
return value.length === 16;
}
if ( validTypes & 0x0002 && /^(4)/.test( value ) ) { // Visa
if ( validTypes & 0x0002 && /^(4)/.test( value ) ) { //visa
return value.length === 16;
}
if ( validTypes & 0x0004 && /^(3[47])/.test( value ) ) { // Amex
if ( validTypes & 0x0004 && /^(3[47])/.test( value ) ) { //amex
return value.length === 15;
}
if ( validTypes & 0x0008 && /^(3(0[012345]|[68]))/.test( value ) ) { // Dinersclub
if ( validTypes & 0x0008 && /^(3(0[012345]|[68]))/.test( value ) ) { //dinersclub
return value.length === 14;
}
if ( validTypes & 0x0010 && /^(2(014|149))/.test( value ) ) { // Enroute
if ( validTypes & 0x0010 && /^(2(014|149))/.test( value ) ) { //enroute
return value.length === 15;
}
if ( validTypes & 0x0020 && /^(6011)/.test( value ) ) { // Discover
if ( validTypes & 0x0020 && /^(6011)/.test( value ) ) { //discover
return value.length === 16;
}
if ( validTypes & 0x0040 && /^(3)/.test( value ) ) { // Jcb
if ( validTypes & 0x0040 && /^(3)/.test( value ) ) { //jcb
return value.length === 16;
}
if ( validTypes & 0x0040 && /^(2131|1800)/.test( value ) ) { // Jcb
if ( validTypes & 0x0040 && /^(2131|1800)/.test( value ) ) { //jcb
return value.length === 15;
}
if ( validTypes & 0x0080 ) { // Unknown
if ( validTypes & 0x0080) { //unknown
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/additional/dateITA.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $.validator.addMethod( "dateITA", function( value, element ) {
mm = parseInt( adata[ 1 ], 10 );
aaaa = parseInt( adata[ 2 ], 10 );
xdata = new Date( Date.UTC( aaaa, mm - 1, gg, 12, 0, 0, 0 ) );
if ( ( xdata.getUTCFullYear() === aaaa ) && ( xdata.getUTCMonth() === mm - 1 ) && ( xdata.getUTCDate() === gg ) ) {
if ( ( xdata.getUTCFullYear() === aaaa ) && ( xdata.getUTCMonth () === mm - 1 ) && ( xdata.getUTCDate() === gg ) ) {
check = true;
} else {
check = false;
Expand Down
16 changes: 7 additions & 9 deletions src/additional/iban.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
* Validation is case-insensitive. Please make sure to normalize input yourself.
*/
$.validator.addMethod( "iban", function( value, element ) {

// Some quick simple tests to prevent needless work
// some quick simple tests to prevent needless work
if ( this.optional( element ) ) {
return true;
}

// Remove spaces and to upper case
// remove spaces and to upper case
var iban = value.replace( / /g, "" ).toUpperCase(),
ibancheckdigits = "",
leadingZeroes = true,
cRest = "",
cOperator = "",
countrycode, ibancheck, charAt, cChar, bbanpattern, bbancountrypatterns, ibanregexp, i, p;

// Check the country code and find the country specific format
// check the country code and find the country specific format
countrycode = iban.substring( 0, 2 );
bbancountrypatterns = {
"AL": "\\d{8}[\\dA-Z]{16}",
Expand Down Expand Up @@ -88,8 +87,7 @@ $.validator.addMethod( "iban", function( value, element ) {
"VG": "[\\dA-Z]{4}\\d{16}"
};

bbanpattern = bbancountrypatterns[ countrycode ];

bbanpattern = bbancountrypatterns[countrycode];
// As new countries will start using IBAN in the
// future, we only check if the countrycode is known.
// This prevents false negatives, while almost all
Expand All @@ -100,11 +98,11 @@ $.validator.addMethod( "iban", function( value, element ) {
if ( typeof bbanpattern !== "undefined" ) {
ibanregexp = new RegExp( "^[A-Z]{2}\\d{2}" + bbanpattern + "$", "" );
if ( !( ibanregexp.test( iban ) ) ) {
return false; // Invalid country specific format
return false; // invalid country specific format
}
}

// Now check the checksum, first convert to digits
// now check the checksum, first convert to digits
ibancheck = iban.substring( 4, iban.length ) + iban.substring( 0, 4 );
for ( i = 0; i < ibancheck.length; i++ ) {
charAt = ibancheck.charAt( i );
Expand All @@ -116,7 +114,7 @@ $.validator.addMethod( "iban", function( value, element ) {
}
}

// Calculate the result of: ibancheckdigits % 97
// calculate the result of: ibancheckdigits % 97
for ( p = 0; p < ibancheckdigits.length; p++ ) {
cChar = ibancheckdigits.charAt( p );
cOperator = "" + cRest + "" + cChar;
Expand Down
4 changes: 4 additions & 0 deletions src/additional/phonesUK.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
* A number of very detailed GB telephone number RegEx patterns can also be found at:
* http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
*/
<<<<<<< HEAD

// Matches UK landline + mobile, accepting only 01-3 for landline or 07 for mobile to exclude many premium numbers
=======
//Matches UK landline + mobile, accepting only 01-3 for landline or 07 for mobile to exclude many premium numbers
>>>>>>> 572d53257e8b08e4c47ea0b05936e3fdc7f919e9
$.validator.addMethod( "phonesUK", function( phone_number, element ) {
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
Expand Down
2 changes: 1 addition & 1 deletion src/additional/url2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading