silverstripe-userforms/client/dist/js/jquery-validation/additional-methods.min.js

1 line
22 KiB
JavaScript
Raw Normal View History

!function(t){"function"==typeof define&&define.amd?define(["jquery","./jquery.validate.min"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}((function(t){return function(){function e(t){return t.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;|&#160;/gi," ").replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g,"")}t.validator.addMethod("maxWords",(function(t,a,d){return this.optional(a)||e(t).match(/\b\w+\b/g).length<=d}),t.validator.format("Please enter {0} words or less.")),t.validator.addMethod("minWords",(function(t,a,d){return this.optional(a)||e(t).match(/\b\w+\b/g).length>=d}),t.validator.format("Please enter at least {0} words.")),t.validator.addMethod("rangeWords",(function(t,a,d){var r=e(t),i=/\b\w+\b/g;return this.optional(a)||r.match(i).length>=d[0]&&r.match(i).length<=d[1]}),t.validator.format("Please enter between {0} and {1} words."))}(),t.validator.addMethod("abaRoutingNumber",(function(t){var e=0,a=t.split(""),d=a.length;if(9!==d)return!1;for(var r=0;r<d;r+=3)e+=3*parseInt(a[r],10)+7*parseInt(a[r+1],10)+parseInt(a[r+2],10);return 0!==e&&e%10==0}),"Please enter a valid routing number."),t.validator.addMethod("accept",(function(e,a,d){var r,i,n="string"==typeof d?d.replace(/\s/g,""):"image/*",o=this.optional(a);if(o)return o;if("file"===t(a).attr("type")&&(n=n.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g,"\\$&").replace(/,/g,"|").replace(/\/\*/g,"/.*"),a.files&&a.files.length))for(i=new RegExp(".?("+n+")$","i"),r=0;r<a.files.length;r++)if(!a.files[r].type.match(i))return!1;return!0}),t.validator.format("Please enter a value with a valid mimetype.")),t.validator.addMethod("alphanumeric",(function(t,e){return this.optional(e)||/^\w+$/i.test(t)}),"Letters, numbers, and underscores only please."),t.validator.addMethod("bankaccountNL",(function(t,e){if(this.optional(e))return!0;if(!/^[0-9]{9}|([0-9]{2} ){3}[0-9]{3}$/.test(t))return!1;var a,d=t.replace(/ /g,""),r=0,i=d.length;for(a=0;a<i;a++)r+=(i-a)*d.substring(a,a+1);return r%11==0}),"Please specify a valid bank account number."),t.validator.addMethod("bankorgiroaccountNL",(function(e,a){return this.optional(a)||t.validator.methods.bankaccountNL.call(this,e,a)||t.validator.methods.giroaccountNL.call(this,e,a)}),"Please specify a valid bank or giro account number."),t.validator.addMethod("bic",(function(t,e){return this.optional(e)||/^([A-Z]{6}[A-Z2-9][A-NP-Z1-9])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test(t.toUpperCase())}),"Please specify a valid BIC code."),t.validator.addMethod("cifES",(function(t,e){"use strict";function a(t){return t%2==0}if(this.optional(e))return!0;var d,r,i,n,o=new RegExp(/^([ABCDEFGHJKLMNPQRSUVW])(\d{7})([0-9A-J])$/gi),s=t.substring(0,1),l=t.substring(1,8),u=t.substring(8,9),f=0,h=0;if(9!==t.length||!o.test(t))return!1;for(d=0;d<l.length;d++)r=parseInt(l[d],10),a(d)?h+=(r*=2)<10?r:r-9:f+=r;return i=(10-(f+h).toString().substr(-1)).toString(),i=parseInt(i,10)>9?"0":i,n="JABCDEFGHI".substr(i,1).toString(),s.match(/[ABEH]/)?u===i:s.match(/[KPQS]/)?u===n:u===i||u===n}),"Please specify a valid CIF number."),t.validator.addMethod("cnhBR",(function(t){if(11!==(t=t.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,"")).length)return!1;var e,a,d,r,i,n=0,o=0;if(e=t.charAt(0),new Array(12).join(e)===t)return!1;for(r=0,i=9,0;r<9;++r,--i)n+=+t.charAt(r)*i;for((a=n%11)>=10&&(a=0,o=2),n=0,r=0,i=1,0;r<9;++r,++i)n+=+t.charAt(r)*i;return(d=n%11)>=10?d=0:d-=o,String(a).concat(d)===t.substr(-2)}),"Please specify a valid CNH number."),t.validator.addMethod("cnpjBR",(function(t,e){"use strict";if(this.optional(e))return!0;if(14!==(t=t.replace(/[^\d]+/g,"")).length)return!1;if("00000000000000"===t||"11111111111111"===t||"22222222222222"===t||"33333333333333"===t||"44444444444444"===t||"55555555555555"===t||"66666666666666"===t||"77777777777777"===t||"88888888888888"===t||"99999999999999"===t)return!1;for(var a=t.length-2,d=t.substring(0,a),r=t.substring(a),i=0,n=a-7,o=a;o>=1;o--)i+=d.charAt(a-o)*n--,n<2&&(n=9);var s=i%11<2?0:11-i%11;if(s!==parseInt(r.charAt(0),10))return!1;a+=1,d=t.substring(0,a),i=0,n=a-7;for(var l=a;l>=1;l--)i+=d