Skip to content

Commit

Permalink
Item15157: updated jquery.validate
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jul 15, 2022
1 parent 41a111a commit 8a42a96
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 160 deletions.
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/VALIDATE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'Validate',
version => '1.19.4_1',
version => '1.19.6_1',
author => 'Joern Zaefferer',
homepage => 'http://jqueryvalidation.org/',
javascript => ['pkg.js'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* jQuery Validation Plugin v1.19.4-pre
* jQuery Validation Plugin v1.19.6-pre
*
* https://jqueryvalidation.org/
*
* Copyright (c) 2021 Jörn Zaefferer
* Copyright (c) 2022 Jörn Zaefferer
* Released under the MIT license
*/
(function( factory ) {
Expand Down Expand Up @@ -119,7 +119,7 @@ $.validator.addMethod( "accept", function( value, element, param ) {

$.validator.addMethod( "alphanumeric", function( value, element ) {
return this.optional( element ) || /^\w+$/i.test( value );
}, "Letters, numbers, and underscores only please" );
}, "Letters, numbers, and underscores only please." );

/*
* Dutch bank account numbers (not 'giro' numbers) have 9 digits
Expand All @@ -146,13 +146,13 @@ $.validator.addMethod( "bankaccountNL", function( value, element ) {
sum = sum + factor * digit;
}
return sum % 11 === 0;
}, "Please specify a valid bank account number" );
}, "Please specify a valid bank account number." );

$.validator.addMethod( "bankorgiroaccountNL", function( value, element ) {
return this.optional( element ) ||
( $.validator.methods.bankaccountNL.call( this, value, element ) ) ||
( $.validator.methods.giroaccountNL.call( this, value, element ) );
}, "Please specify a valid bank or giro account number" );
}, "Please specify a valid bank or giro account number." );

/**
* BIC is the business identifier code (ISO 9362). This BIC check is not a guarantee for authenticity.
Expand All @@ -171,7 +171,7 @@ $.validator.addMethod( "bankorgiroaccountNL", function( value, element ) {
*/
$.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() );
}, "Please specify a valid BIC code" );
}, "Please specify a valid BIC code." );

/*
* Código de identificación fiscal ( CIF ) is the tax identification code for Spanish legal entities
Expand Down Expand Up @@ -336,7 +336,7 @@ $.validator.addMethod( "cnhBR", function( value ) {

return ( String( firstCN ).concat( secondCN ) === value.substr( -2 ) );

}, "Please specify a valid CNH number" );
}, "Please specify a valid CNH number." );

/*
* Brazillian value number (Cadastrado de Pessoas Juridica).
Expand Down Expand Up @@ -411,7 +411,7 @@ $.validator.addMethod( "cnpjBR", function( value, element ) {

return true;

}, "Please specify a CNPJ value number" );
}, "Please specify a CNPJ value number." );

/*
* Brazillian CPF number (Cadastrado de Pessoas Físicas) is the equivalent of a Brazilian tax registration number.
Expand Down Expand Up @@ -477,7 +477,7 @@ $.validator.addMethod( "cpfBR", function( value, element ) {
}
return false;

}, "Please specify a valid CPF number" );
}, "Please specify a valid CPF number." );

// https://jqueryvalidation.org/creditcard-method/
// based on https://en.wikipedia.org/wiki/Luhn_algorithm
Expand Down Expand Up @@ -630,7 +630,7 @@ $.validator.addMethod( "currency", function( value, element, param ) {
regex = new RegExp( regex );
return this.optional( element ) || regex.test( value );

}, "Please specify a valid currency" );
}, "Please specify a valid currency." );

$.validator.addMethod( "dateFA", function( value, element ) {
return this.optional( element ) || /^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test( value );
Expand Down Expand Up @@ -691,7 +691,7 @@ $.validator.addMethod( "extension", function( value, element, param ) {
*/
$.validator.addMethod( "giroaccountNL", function( value, element ) {
return this.optional( element ) || /^[0-9]{1,7}$/.test( value );
}, "Please specify a valid giro account number" );
}, "Please specify a valid giro account number." );

$.validator.addMethod( "greaterThan", function( value, element, param ) {
var target = $( param );
Expand Down Expand Up @@ -852,11 +852,11 @@ $.validator.addMethod( "iban", function( value, element ) {
cRest = cOperator % 97;
}
return cRest === 1;
}, "Please specify a valid IBAN" );
}, "Please specify a valid IBAN." );

$.validator.addMethod( "integer", function( value, element ) {
return this.optional( element ) || /^-?\d+$/.test( value );
}, "A positive or negative non-decimal number please" );
}, "A positive or negative non-decimal number please." );

$.validator.addMethod( "ipv4", function( value, element ) {
return this.optional( element ) || /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test( value );
Expand Down Expand Up @@ -892,11 +892,11 @@ $.validator.addMethod( "lessThanEqual", function( value, element, param ) {

$.validator.addMethod( "lettersonly", function( value, element ) {
return this.optional( element ) || /^[a-z]+$/i.test( value );
}, "Letters only please" );
}, "Letters only please." );

$.validator.addMethod( "letterswithbasicpunc", function( value, element ) {
return this.optional( element ) || /^[a-z\-.,()'"\s]+$/i.test( value );
}, "Letters or punctuation only please" );
}, "Letters or punctuation only please." );

// Limit the number of files in a FileList.
$.validator.addMethod( "maxfiles", function( value, element, param ) {
Expand Down Expand Up @@ -957,12 +957,12 @@ $.validator.addMethod( "maxsizetotal", function( value, element, param ) {

$.validator.addMethod( "mobileNL", function( value, element ) {
return this.optional( element ) || /^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)6((\s|\s?\-\s?)?[0-9]){8}$/.test( value );
}, "Please specify a valid mobile number" );
}, "Please specify a valid mobile number." );

$.validator.addMethod( "mobileRU", function( phone_number, element ) {
var ruPhone_number = phone_number.replace( /\(|\)|\s+|-/g, "" );
return this.optional( element ) || ruPhone_number.length > 9 && /^((\+7|7|8)+([0-9]){10})$/.test( ruPhone_number );
}, "Please specify a valid mobile number" );
}, "Please specify a valid mobile number." );

/* For UK phone functions, do the following server side processing:
* Compare original input with this RegEx pattern:
Expand All @@ -976,7 +976,7 @@ $.validator.addMethod( "mobileUK", function( phone_number, element ) {
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
phone_number.match( /^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/ );
}, "Please specify a valid mobile number" );
}, "Please specify a valid mobile number." );

$.validator.addMethod( "netmask", function( value, element ) {
return this.optional( element ) || /^(254|252|248|240|224|192|128)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)/i.test( value );
Expand Down Expand Up @@ -1132,15 +1132,15 @@ $.validator.addMethod( "nisBR", function( value ) {
} else {
return false;
}
}, "Please specify a valid NIS/PIS number" );
}, "Please specify a valid NIS/PIS number." );

$.validator.addMethod( "notEqualTo", function( value, element, param ) {
return this.optional( element ) || !$.validator.methods.equalTo.call( this, value, element, param );
}, "Please enter a different value, values must not be the same." );

$.validator.addMethod( "nowhitespace", function( value, element ) {
return this.optional( element ) || /^\S+$/i.test( value );
}, "No white space please" );
}, "No white space please." );

/**
* Return true if the field value matches the given format RegExp
Expand Down Expand Up @@ -1194,7 +1194,7 @@ $.validator.addMethod( "phonePL", function( phone_number, element ) {
phone_number = phone_number.replace( /\s+/g, "" );
var regexp = /^(?:(?:(?:\+|00)?48)|(?:\(\+?48\)))?(?:1[2-8]|2[2-69]|3[2-49]|4[1-68]|5[0-9]|6[0-35-9]|[7-8][1-9]|9[145])\d{7}$/;
return this.optional( element ) || regexp.test( phone_number );
}, "Please specify a valid phone number" );
}, "Please specify a valid phone number." );

/* For UK phone functions, do the following server side processing:
* Compare original input with this RegEx pattern:
Expand All @@ -1210,7 +1210,7 @@ $.validator.addMethod( "phonesUK", function( phone_number, element ) {
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
phone_number.match( /^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/ );
}, "Please specify a valid uk phone number" );
}, "Please specify a valid uk phone number." );

/* For UK phone functions, do the following server side processing:
* Compare original input with this RegEx pattern:
Expand All @@ -1224,7 +1224,7 @@ $.validator.addMethod( "phoneUK", function( phone_number, element ) {
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
phone_number.match( /^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/ );
}, "Please specify a valid phone number" );
}, "Please specify a valid phone number." );

/**
* Matches US phone number format
Expand All @@ -1246,7 +1246,7 @@ $.validator.addMethod( "phoneUS", function( phone_number, element ) {
phone_number = phone_number.replace( /\s+/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
phone_number.match( /^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]\d{2}-?\d{4}$/ );
}, "Please specify a valid phone number" );
}, "Please specify a valid phone number." );

/*
* Valida CEPs do brasileiros:
Expand Down Expand Up @@ -1275,21 +1275,21 @@ $.validator.addMethod( "postalcodeBR", function( cep_value, element ) {
*/
$.validator.addMethod( "postalCodeCA", function( value, element ) {
return this.optional( element ) || /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] *\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i.test( value );
}, "Please specify a valid postal code" );
}, "Please specify a valid postal code." );

/* Matches Italian postcode (CAP) */
$.validator.addMethod( "postalcodeIT", function( value, element ) {
return this.optional( element ) || /^\d{5}$/.test( value );
}, "Please specify a valid postal code" );
}, "Please specify a valid postal code." );

$.validator.addMethod( "postalcodeNL", function( value, element ) {
return this.optional( element ) || /^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test( value );
}, "Please specify a valid postal code" );
}, "Please specify a valid postal code." );

// Matches UK postcode. Does not match to UK Channel Islands that have their own postcodes (non standard UK)
$.validator.addMethod( "postcodeUK", function( value, element ) {
return this.optional( element ) || /^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test( value );
}, "Please specify a valid UK postcode" );
}, "Please specify a valid UK postcode." );

/*
* Lets you say "at least X inputs that match selector Y must be filled."
Expand Down Expand Up @@ -1426,24 +1426,24 @@ $.validator.addMethod( "stateUS", function( value, element, options ) {

regex = caseSensitive ? new RegExp( regex ) : new RegExp( regex, "i" );
return this.optional( element ) || regex.test( value );
}, "Please specify a valid state" );
}, "Please specify a valid state." );

// TODO check if value starts with <, otherwise don't try stripping anything
$.validator.addMethod( "strippedminlength", function( value, element, param ) {
return $( value ).text().length >= param;
}, $.validator.format( "Please enter at least {0} characters" ) );
}, $.validator.format( "Please enter at least {0} characters." ) );

$.validator.addMethod( "time", function( value, element ) {
return this.optional( element ) || /^([01]\d|2[0-3]|[0-9])(:[0-5]\d){1,2}$/.test( value );
}, "Please enter a valid time, between 00:00 and 23:59" );
}, "Please enter a valid time, between 00:00 and 23:59." );

$.validator.addMethod( "time12h", function( value, element ) {
return this.optional( element ) || /^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test( value );
}, "Please enter a valid time in 12-hour am/pm format" );
}, "Please enter a valid time in 12-hour am/pm format." );

// Same as url, but TLD is optional
$.validator.addMethod( "url2", function( value, element ) {
return this.optional( element ) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test( value );
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?)|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff])|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62}\.)))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
}, $.validator.messages.url );

/**
Expand Down Expand Up @@ -1503,10 +1503,10 @@ $.validator.addMethod( "vinUS", function( v ) {

$.validator.addMethod( "zipcodeUS", function( value, element ) {
return this.optional( element ) || /^\d{5}(-\d{4})?$/.test( value );
}, "The specified US ZIP Code is invalid" );
}, "The specified US ZIP Code is invalid." );

$.validator.addMethod( "ziprange", function( value, element ) {
return this.optional( element ) || /^90[2-5]\d\{2\}-\d{4}$/.test( value );
}, "Your ZIP-code must be in the range 902xx-xxxx to 905xx-xxxx" );
}, "Your ZIP-code must be in the range 902xx-xxxx to 905xx-xxxx." );
return $;
}));

0 comments on commit 8a42a96

Please sign in to comment.