PageSourceSearch

https://c3-static.comparably.com/1.576/eyf/js/framework.inputvalidation.js?1.576

js comparably.com collected 2026-10-01 07:12:49 UTC 28,361 bytes, 409 lines download raw bytes

1/*!
2 * Copyright (c) 2015 Chris O'Hara <[email protected]>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23!function(e,t){"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&"object"==typeof define.amd?define(t):"function"==typeof define&&"object"==typeof define.petal?define(e,[],t):this[e]=t()}("validator",function(e){"use strict";function t(e){var t,r,n,i,o=e.match(B);if(o){if(t=o[21],!t)return o[12]?null:0;if("z"===t||"Z"===t)return 0;r=o[22],-1!==t.indexOf(":")?(n=parseInt(o[23]),i=parseInt(o[24])):(n=0,i=parseInt(o[23]))}else{if(e=e.toLowerCase(),t=e.match(/(?:\s|gmt\s*)(-|\+)(\d{1,4})(\s|$)/),!t)return-1!==e.indexOf("gmt")?0:null;r=t[1];var a=t[2];3===a.length&&(a="0"+a),a.length<=2?(n=0,i=parseInt(a)):(n=parseInt(a.slice(0,2)),i=parseInt(a.slice(2,4)))}return(60*n+i)*("-"===r?1:-1)}function r(e,t){e=e||{};for(var r in t)"undefined"==typeof e[r]&&(e[r]=t[r]);return e}function n(e){var t="(\\"+e.symbol.replace(/\./g,"\\.")+")"+(e.require_symbol?"":"?"),r="-?",n="[1-9]\\d*",i="[1-9]\\d{0,2}(\\"+e.thousands_separator+"\\d{3})*",o=["0",n,i],a="("+o.join("|")+")?",s="(\\"+e.decimal_separator+"\\d{2})?",u=a+s;return e.allow_negatives&&!e.parens_for_negatives&&(e.negative_sign_after_digits?u+=r:e.negative_sign_before_digits&&(u=r+u)),e.allow_negative_sign_placeholder?u="( (?!\\-))?"+u:e.allow_space_after_symbol?u=" ?"+u:e.allow_space_after_digits&&(u+="( (?!$))?"),e.symbol_after_digits?u+=t:u=t+u,e.allow_negatives&&(e.parens_for_negatives?u="(\\("+u+"\\)|"+u+")":e.negative_sign_before_digits||e.negative_sign_after_digits||(u=r+u)),new RegExp("^(?!-? )(?=.*\\d)"+u+"$")}e={version:"4.9.0",coerce:!0};for(var i,o=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,a=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,s=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,u=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,l=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\u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":/^(\+?64|0)2\d{7,9}$/,"en-ZA":/^(\+?27|0)\d{9}$/,"en-ZM":/^(\+?26)?09[567]\d{7}$/,"es-ES":/^(\+?34)?(6\d{1}|7[1234])\d{7}$/,"fi-FI":/^(\+?358|0)\s?(4(0|1|2|4|5)?|50)\s?(\d\s?){4,8}\d$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"nb-NO":/^(\+?47)?[49]\d{7}$/,"nn-NO":/^(\+?47)?[49]\d{7}$/,"pt-BR":/^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,"pt-PT":/^(\+?351)?9[1236]\d{7}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/,"vi-VN":/^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,"zh-CN":/^(\+?0?86\-?)?((13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}|170[059]\d{7})$/,"zh-TW":/^(\+?886\-?|0)?9\d{8}$/},B=/^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;e.extend=function(t,r){e[t]=function(){var t=Array.prototype.slice.call(arguments);return t[0]=e.toString(t[0]),r.apply(e,t)}},e.init=function(){for(var t in e)"function"==typeof e[t]&&"toString"!==t&&"toDate"!==t&&"extend"!==t&&"init"!==t&&"isServerSide"!==t&&e.extend(t,e[t])},e.isServerSide=function(){return"object"==typeof module&&module&&"object"==typeof module.exports&&"object"==typeof process&&"function"==typeof require};var R=null;e.deprecation=function(t){if(null===R){if(!e.isServerSide())return;R=require("depd")("validator")}R(t)},e.toString=function(t){if("string"!=typeof t){if(!e.coerce)throw new Error("this library validates strings only");e.deprecation("you tried to validate a "+typeof t+" but this library (validator.js) validates strings only. Please update your code as this will be an error soon.")}return"object"==typeof t&&null!==t?t="function"==typeof t.toString?t.toString():"[object Object]":(null===t||"undefined"==typeof t||isNaN(t)&&!t.length)&&(t=""),""+t},e.toDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)?e:(e=Date.parse(e),isNaN(e)?null:new Date(e))},e.toFloat=function(e){return parseFloat(e)},e.toInt=function(e,t){return parseInt(e,t||10)},e.toBoolean=function(e,t){return t?"1"===e||"true"===e:"0"!==e&&"false"!==e&&""!==e},e.equals=function(t,r){return t===e.toString(r)},e.contains=function(t,r){return t.indexOf(e.toString(r))>=0},e.matches=function(e,t,r){return"[object RegExp]"!==Object.prototype.toString.call(t)&&(t=new RegExp(t,r)),t.test(e)};var U={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0};e.isEmail=function(t,n){if(n=r(n,U),n.allow_display_name){var i=t.match(l);i&&(t=i[1])}var f=t.split("@"),c=f.pop(),d=f.join("@"),p=c.toLowerCase();if(("gmail.com"===p||"googlemail.com"===p)&&(d=d.replace(/\./g,"").toLowerCase()),!e.isByteLength(d,{max:64})||!e.isByteLength(c,{max:256}))return!1;if(!e.isFQDN(c,{require_tld:n.require_tld}))return!1;if('"'===d[0])return d=d.slice(1,d.length-1),n.allow_utf8_local_part?u.test(d):a.test(d);for(var g=n.allow_utf8_local_part?s:o,F=d.split("."),_=0;_<F.length;_++)if(!g.test(F[_]))return!1;return!0};var q={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1};e.isURL=function(t,n){if(!t||t.length>=2083||/\s/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;n=r(n,q);var i,o,a,s,u,l,f;if(f=t.split("://"),f.length>1){if(i=f.shift(),n.require_valid_protocol&&-1===n.protocols.indexOf(i))return!1}else{if(n.require_protocol)return!1;n.allow_protocol_relative_urls&&"//"===t.substr(0,2)&&(f[0]=t.substr(2))}
23return t=f.join("://"),f=t.split("#"),t=f.shift(),f=t.split("?"),t=f.shift(),f=t.split("/"),t=f.shift(),f=t.split("@"),f.length>1&&(o=f.shift(),o.indexOf(":")>=0&&o.split(":").length>2)?!1:(s=f.join("@"),f=s.split(":"),a=f.shift(),f.length&&(l=f.join(":"),u=parseInt(l,10),!/^[0-9]+$/.test(l)||0>=u||u>65535)?!1:e.isIP(a)||e.isFQDN(a,n)||"localhost"===a?n.host_whitelist&&-1===n.host_whitelist.indexOf(a)?!1:n.host_blacklist&&-1!==n.host_blacklist.indexOf(a)?!1:!0:!1)},e.isMACAddress=function(e){return g.test(e)},e.isIP=function(t,r){if(r=r?r+"":"",!r)return e.isIP(t,4)||e.isIP(t,6);if("4"===r){if(!F.test(t))return!1;var n=t.split(".").sort(function(e,t){return e-t});return n[3]<=255}if("6"===r){var i=t.split(":"),o=!1,a=e.isIP(i[i.length-1],4),s=a?7:8;if(i.length>s)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===t.substr(t.length-2)&&(i.pop(),i.pop(),o=!0);for(var u=0;u<i.length;++u)if(""===i[u]&&u>0&&u<i.length-1){if(o)return!1;o=!0}else if(a&&u==i.length-1);else if(!_.test(i[u]))return!1;return o?i.length>=1:i.length===s}return!1};var L={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1};e.isFQDN=function(e,t){t=r(t,L),t.allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));var n=e.split(".");if(t.require_tld){var i=n.pop();if(!n.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(i))return!1}for(var o,a=0;a<n.length;a++){if(o=n[a],t.allow_underscores){if(o.indexOf("__")>=0)return!1;o=o.replace(/_/g,"")}if(!/^[a-z\u00a1-\uffff0-9-]+$/i.test(o))return!1;if(/[\uff01-\uff5e]/.test(o))return!1;if("-"===o[0]||"-"===o[o.length-1])return!1}return!0},e.isBoolean=function(e){return["true","false","1","0"].indexOf(e)>=0},e.isAlpha=function(e,t){if(t=t||"en-US",t in h)return h[t].test(e);throw new Error("Invalid locale '"+t+"'")},e.isAlphanumeric=function(e,t){if(t=t||"en-US",t in v)return v[t].test(e);throw new Error("Invalid locale '"+t+"'")},e.isNumeric=function(e){return A.test(e)},e.isDecimal=function(e){return""!==e&&D.test(e)},e.isHexadecimal=function(e){return b.test(e)},e.isHexColor=function(e){return S.test(e)},e.isLowercase=function(e){return e===e.toLowerCase()},e.isUppercase=function(e){return e===e.toUpperCase()},e.isInt=function(e,t){return t=t||{},w.test(e)&&(!t.hasOwnProperty("min")||e>=t.min)&&(!t.hasOwnProperty("max")||e<=t.max)},e.isFloat=function(e,t){return t=t||{},""===e||"."===e?!1:y.test(e)&&(!t.hasOwnProperty("min")||e>=t.min)&&(!t.hasOwnProperty("max")||e<=t.max)},e.isDivisibleBy=function(t,r){return e.toFloat(t)%parseInt(r,10)===0},e.isNull=function(e){return 0===e.length},e.isLength=function(e,t){var r,n;"object"==typeof t?(r=t.min||0,n=t.max):(r=arguments[1],n=arguments[2]);var i=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],o=e.length-i.length;return o>=r&&("undefined"==typeof n||n>=o)},e.isByteLength=function(e,t){var r,n;"object"==typeof t?(r=t.min||0,n=t.max):(r=arguments[1],n=arguments[2]);var i=encodeURI(e).split(/%..|./).length-1;return i>=r&&("undefined"==typeof n||n>=i)},e.isUUID=function(e,t){var r=x[t?t:"all"];return r&&r.test(e)},e.isDate=function(e){var r=new Date(Date.parse(e));if(isNaN(r))return!1;var n=t(e);if(null!==n){var i=r.getTimezoneOffset()-n;r=new Date(r.getTime()+6e4*i)}var o,a,s,u=String(r.getDate());return(a=e.match(/(^|[^:\d])[23]\d([^:\d]|$)/g))?(o=a.map(function(e){return e.match(/\d+/g)[0]}).join("/"),s=String(r.getFullYear()).slice(-2),o===u||o===s?!0:o===u+"/"+s||o===s+"/"+u?!0:!1):!0},e.isAfter=function(t,r){var n=e.toDate(r||new Date),i=e.toDate(t);return!!(i&&n&&i>n)},e.isBefore=function(t,r){var n=e.toDate(r||new Date),i=e.toDate(t);return!!(i&&n&&n>i)},e.isIn=function(t,r){var n;if("[object Array]"===Object.prototype.toString.call(r)){var i=[];for(n in r)i[n]=e.toString(r[n]);return i.indexOf(t)>=0}return"object"==typeof r?r.hasOwnProperty(t):r&&"function"==typeof r.indexOf?r.indexOf(t)>=0:!1},e.isWhitelisted=function(e,t){for(var r=e.length-1;r>=0;r--)if(-1===t.indexOf(e[r]))return!1;return!0},e.isCreditCard=function(e){var t=e.replace(/[^0-9]+/g,"");if(!f.test(t))return!1;for(var r,n,i,o=0,a=t.length-1;a>=0;a--)r=t.substring(a,a+1),n=parseInt(r,10),i?(n*=2,o+=n>=10?n%10+1:n):o+=n,i=!i;return!!(o%10===0?t:!1)},e.isISIN=function(e){if(!c.test(e))return!1;for(var t,r,n=e.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),i=0,o=!0,a=n.length-2;a>=0;a--)t=n.substring(a,a+1),r=parseInt(t,10),o?(r*=2,i+=r>=10?r+1:r):i+=r,o=!o;return parseInt(e.substr(e.length-1),10)===(1e4-i)%10},e.isISBN=function(t,r){if(r=r?r+"":"",!r)return e.isISBN(t,10)||e.isISBN(t,13);var n,i=t.replace(/[\s-]+/g,""),o=0;if("10"===r){if(!d.test(i))return!1;for(n=0;9>n;n++)o+=(n+1)*i.charAt(n);if(o+="X"===i.charAt(9)?100:10*i.charAt(9),o%11===0)return!!i}else if("13"===r){if(!p.test(i))return!1;var a=[1,3];for(n=0;12>n;n++)o+=a[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10===0)return!!i}return!1},e.isMobilePhone=function(e,t){return t in C?C[t].test(e):!1};var P={symbol:"$",require_symbol:!1,allow_space_after_symbol:!1,symbol_after_digits:!1,allow_negatives:!0,parens_for_negatives:!1,negative_sign_before_digits:!1,negative_sign_after_digits:!1,allow_negative_sign_placeholder:!1,thousands_separator:",",decimal_separator:".",allow_space_after_digits:!1};e.isCurrency=function(e,t){return t=r(t,P),n(t).test(e)}
23,e.isJSON=function(e){try{var t=JSON.parse(e);return!!t&&"object"==typeof t}catch(r){}return!1},e.isMultibyte=function(e){return I.test(e)},e.isAscii=function(e){return E.test(e)},e.isFullWidth=function(e){return O.test(e)},e.isHalfWidth=function(e){return Z.test(e)},e.isVariableWidth=function(e){return O.test(e)&&Z.test(e)},e.isSurrogatePair=function(e){return N.test(e)},e.isBase64=function(e){return j.test(e)},e.isMongoId=function(t){return e.isHexadecimal(t)&&24===t.length},e.isISO8601=function(e){return B.test(e)},e.ltrim=function(e,t){var r=t?new RegExp("^["+t+"]+","g"):/^\s+/g;return e.replace(r,"")},e.rtrim=function(e,t){var r=t?new RegExp("["+t+"]+$","g"):/\s+$/g;return e.replace(r,"")},e.trim=function(e,t){var r=t?new RegExp("^["+t+"]+|["+t+"]+$","g"):/^\s+|\s+$/g;return e.replace(r,"")},e.escape=function(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\//g,"&#x2F;").replace(/\`/g,"&#96;")},e.stripLow=function(t,r){var n=r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return e.blacklist(t,n)},e.whitelist=function(e,t){return e.replace(new RegExp("[^"+t+"]+","g"),"")},e.blacklist=function(e,t){return e.replace(new RegExp("["+t+"]+","g"),"")};var z={lowercase:!0,remove_dots:!0,remove_extension:!0};return e.normalizeEmail=function(t,n){if(n=r(n,z),!e.isEmail(t))return!1;var i=t.split("@",2);if(i[1]=i[1].toLowerCase(),"gmail.com"===i[1]||"googlemail.com"===i[1]){if(n.remove_extension&&(i[0]=i[0].split("+")[0]),n.remove_dots&&(i[0]=i[0].replace(/\./g,"")),!i[0].length)return!1;i[0]=i[0].toLowerCase(),i[1]="gmail.com"}else n.lowercase&&(i[0]=i[0].toLowerCase());return i.join("@")},e.init(),e});
24/*globals validator */
25
26validator.extend("isPassword", function (str) {
27    return (str && str.length && str.length >= 6 && str.length <= 32 && /^[a-zA-Z0-9\!\@\#\$\%\^\&\*\(\)]+$/.test(str));
28});
29
30validator.extend("isPasswordMinimum8Characters", function (str) {
31    return (str && str.length && str.length >= 8 && str.length <= 32 && /^[a-zA-Z0-9\!\@\#\$\%\^\&\*\(\)]+$/.test(str));
32});
33
34validator.extend("isPasswordMinimum1Each", function (str) {
35    return (str && str.length && str.length >= 8 && str.length <= 32 &&
36        /^[a-zA-Z0-9\!\@\#\$\%\^\&\*\(\)]+$/.test(str) &&
37        str.match(/[a-z]/) &&
38        str.match(/[A-Z]/) &&
39        str.match(/[0-9]/) &&
40        str.match(/[\!\@\#\$\%\^\&\*\(\)]/)
41    );
42});
43
44validator.extend("isValid", function (val, check) {
45    return check;
46});
47
48validator.extend("isValidFullName",function (str) {
49
50    if (!str || !str.length)
51        return false;
52
53    var spl = str.split(" ");
54
55    if (!spl || spl.length < 2)
56        return false;
57
58    for (var i = 0; i < spl.length; i++) {
59
60        if (this.isValidName(spl[i]) == false)
61            return false;
62    }
63
64    return true;
65});
66
67validator.extend("isValidDesiredBenefits", function(str){
68    return str && str.trim && str.trim().length && str.trim().length <= 250 && !str.match(/<[^>]*>/);
69});
70
71validator.extend("isValidJobPreference", function(str){
72    if (!str || !str.length) return false;
73    try {
74        var pref = JSON.parse(str);
75        if(!pref || !pref.length) return false;
76        return true;
77    }
78    catch (e) {
79        return false;
80
81    }
82    return false;
83});
84
85
86
87validator.extend("isValidInsightsAnswers", function(a) {
88    if(!a) return true;
89    var answers = JSON.parse(a);
90    if(!answers || !answers.length) return true;
91    var TEXTAREA_LIMIT = 300;
92    var STACKED_TEXTAREA_LIMIT = 70;
93    var DEFAULT_TEXT_QUESTION_LIMIT = 5000;
94
95    function limit(type){
96        if(type === 3) return TEXTAREA_LIMIT;
97        else if(type === 7) return STACKED_TEXTAREA_LIMIT;
98        else return DEFAULT_TEXT_QUESTION_LIMIT;
99    }
100
101    var valid = true;
102    for(var i = 0; i < answers.length; i++){
103        var answer = answers[i];
104        if(answer.answerText && answer.questionType){
105            if(answer.answerText.length > limit(parseInt(answer.questionType))) {
106                valid = false;
107                break;
108            }
109        }
110    }
111    return valid;
112});
113
114validator.extend("isValidEmail", function (str) {
115    return str && str.length && str.toLowerCase && (str = str.toLowerCase()) && this.isEmail(str);
116});
117
118validator.extend("isValidCorporateEmail", function (str, domains) {
119    return str && str.length && str.toLowerCase && (str = str.toLowerCase()) && this.isEmail(str) && (domains || []).indexOf(str.substr(str.indexOf("@") + 1)) !== -1;
120});
121
122validator.extend("isValidLinkedinUrl", function (str) {
123    if(!str) return false;
124    return str.toLowerCase().match("linkedin.com");
125});
126
127validator.extend("isValidPhoneNumber", function (str) {
128    if (!str) return false;
129    return str.length >= 10 && !str.match(/[<>]+/);
130});
131
132validator.extend("hasValue",function (str) {
133    if(!str) return false;
134    return !(!str || !str.length || !str.replace(/\s/gi,"").length);
135});
136
137validator.extend("isValidMissionStatement", function (str) {
138    return str && str.trim && str.trim().length && str.trim().length <= 1000 && !str.match(/<[^>]*>/);
139});
140
141validator.extend("isValidBlurb", function (str) {
142    return str && str.trim && str.trim().length && str.trim().length <= 1000 && !str.match(/<[^>]*>/);
143});
144
145validator.extend("isValidWebAddress", function (str) {
146    if (!str || !str.length) return false;
147
148    var match = str.toLowerCase().match(/^http:|^https:|^www\./);
149    return this.isClean(str) && match && match.length;
150});
151
152validator.extend("isValidApplicantResume", function (jsonData) {
153    if(!jsonData) return false;
154    var resume = null;
155    try{
156        resume = JSON.parse(jsonData);
157    }
158    catch(e){
159        return false;
160    }
161    if(!resume) return false;
162
163    if(!resume.originalname || !resume.originalname.length) return false;
164    var ext = resume.originalname.split('.').pop().toLowerCase();
165
166    var formats = ['pdf', 'doc', 'docx', 'txt'];
167    if(formats.indexOf(ext) == -1){
168        return false;
169    }
170    return true;
171});
172
173validator.extend("isValidApplicantResumeSize", function (jsonData) {
174    if(!jsonData) return false;
175    var resume = null;
176    try{
177        resume = JSON.parse(jsonData);
178    }
179    catch(e){
180        return false;
181    }
182    if(!resume) return false;
183    if(resume.size <= 0 || resume.size > 3000000) return false;
184    return true;
185});
186
187validator.extend("isValidImage", function (img) {
188    if (!img) return false;
189    var image;
190    try {
191      image = JSON.parse(img);
192    } catch (e) {
193        return false;
194    }
195    if (!image) return false;
196    if (!image.mimetype) return false;
197    var mimetype = image.mimetype.toLowerCase();
198    return ["image/gif", "image/png", "image/jpeg"].indexOf(mimetype) !== -1;
199});
200
201validator.extend("isValidImageSize", function (img) {
202    if (!img) return false;
203    var image;
204    try {
205      image = JSON.parse(img);
206    } catch (e) {
207        return false;
208    }
209    if (!image) return false;
210    if (image.size <= 0 || image.size > 2000000) return false;
211    return true;
212});
213
214
215validator.extend("isValidCompanyMediaVideoUrl", function (url) {
216    if(!url) return false;
217    if(url.match(/(http[s]{0,1}:\/\/){0,1}(www\.){0,1}youtube\.com\//)) return true;
218    else if(url.match(/(http[s]{0,1}:\/\/){0,1}(www\.){0,1}youtu\.be\//)) return true;
219    else if(url.match(/(http[s]{0,1}:\/\/){0,1}(www\.){0,1}vimeo\.com\//)) return true;
220    else return false;
221});
222
223validator.extend("isValidCompanyMediaDescription", function (str) {
224    return str && str.trim && str.trim().length && str.trim().length <= 1000 && !str.match(/<[^>]*>/);
225});
226
227validator.extend("isValidCompanyMediaImageSize", function (img) {
228    var image = JSON.parse(img);
229    if(!image) return false;
230    if(image.size <= 0 || image.size > 10000000) return false;
231    return true;
232});
233
234validator.extend("hasCurrencyValue",function (str) {
235    return !(!str || !str.length || !str.replace(/[^0-9]/gi,"").length || isNaN(parseInt(str.replace(/\$/gi,""))));
236});
237
238validator.extend("hasNumericValue",function (str) {
239    return !isNaN(str);
240});
241
242validator.extend("hasIntValue",function (str) {
243    return !(!str || !str.length || !str.replace(/\s/gi,"").length || isNaN(parseInt(str)));
244});
245validator.extend("hasIntValuePositive",function (str) {
246    return !(!str || !str.length || !str.replace(/\s/gi,"").length || isNaN(parseInt(str)) || parseInt(str) < 0);
247});
248validator.extend("hasIntValueOverZero",function (str) {
249    return !(!str || !str.length || !str.replace(/\s/gi,"").length || isNaN(parseInt(str)) || parseInt(str) <= 0);
250});
251
252validator.extend("isValidToCurrentYear",function (str) {
253    // https://en.wikipedia.org/wiki/List_of_oldest_companies
254    // 578 = Kongō Gumi oldest company still in operation
255    return !(!str || !str.length || !str.replace(/\s/gi,"").length || isNaN(parseInt(str)) || parseInt(str) > new Date().getFullYear() || parseInt(str) < 578);
256});
257
258validator.extend("isValidMonthInt",function (str) {
259    return !(!str || !str.length || !str.replace(/\s/gi,"").length || isNaN(parseInt(str)) || parseInt(str) > 11 || parseInt(str) < 0);
260});
261
262validator.extend("isLessThanOrEqualTo",function (str, compare) {
263    return parseInt(str) <= parseInt(compare);
264});
265
266validator.extend("isValueIn", function (str, values) {
267    return values && values.indexOf && values.indexOf(str) !== -1;
268});
269
270validator.extend("isClean", function (str) {
271    return str && str.trim && str.trim().length && !str.match(/<[^>]*>/);
272});
273
274validator.extend("isValidName", function (str) {
275    return str && str.trim && str.trim().length && !str.match(/[<>]+/);
276
277    // var s = str.replace(/[^\w]/gi, "");
278
279    // if (s.length <= 1 || s.length > 16 || !/^[\w]+$/.test(str))
280    //     return false;
281
282    // return true;
283});
284
285validator.extend("isValidSchoolName", function (str) {
286    return str && str.trim && str.trim().length && !str.match(/[<>]+/);
287
288    // var s = str.replace(/[^\w]/gi, "");
289
290    // if (s.length <= 1 || s.length > 200 || !/^[\w]+$/.test(str))
291    //     return false;
292
293    // return true;
294});
295
296validator.extend("isValidMajorName", function (str) {
297    return str && str.trim && str.trim().length && !str.match(/[<>]+/);
298
299    // var s = str.replace(/[^\w]/gi, "");
300
301    // if (s.length <= 1 || s.length > 200 || !/^[\w]+$/.test(str))
302    //     return false;
303
304    // return true;
305});
306
307validator.extend("booleanIsTrue", function(val) {
308    return ["true", true].indexOf(val) !== -1;
309});
310
311validator.extend("isEquals", function(val, compare) {
312    return val === compare;
313});
314
315validator.extend("isNotEquals", function(val, compare) {
316    return val !== compare;
317});
318
319validator.extend("hasMinimumWords", function(val, minimumWordCount) {
320    function getWordCount(str) {
321        var words = (str || "").trim().split(" ");
322        return words.filter(function(word) {
323            return word.trim().length > 0;
324        }).length;
325    }
326
327    return getWordCount(val) >= minimumWordCount;
328});
329
330
331validator.extend("hasMinimumWords5", function(val) {
332    return this.hasMinimumWords(val, 5);
333});
334
335validator.extend("hasMaximumWords", function(val, maximumWordCount) {
336    function getWordCount(str) {
337        var words = (str || "").trim().split(" ");
338        return words.filter(function(word) {
339            return word.trim().length > 0;
340        }).length;
341    }
342    return getWordCount(val) <= maximumWordCount;
343});
344
345validator.extend("hasMaximumWords10", function(val) {
346    return this.hasMaximumWords(val, 10);
347});
348
349validator.extend("hasMaximumCharacters", function(val, max) {
350    return !val || val.length <= max;
351});
352
353validator.extend("hasMinimumCharacters", function(val, min) {
354    return !val || val.length >= min;
355});
356validator.REGEX_NUMID = /^[-+]?\d+$/;
357validator.REGEX_URL = new RegExp("^(?:(?:https?)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?: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-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$", "i");
358validator.REGEX_RESOURCE_URL_SYNC = new RegExp(/https:\/\/(?:[^\.]+\.comparably\.(?:dev|com))|(?:s3-[^\.]+\.amazonaws\.com\/[^\/]+\.comparably\.com\/)/);
359
360validator.extend("isValidUrl",function( url ) {
361    return url && url.length && this.isClean(url) && validator.REGEX_URL.test(url);
362});
363
364validator.extend("isSafeResourceURLSync",function( url ) {
365    return url && url.length && this.isClean(url) && validator.REGEX_RESOURCE_URL_SYNC.test(url);
366});
367
368validator.extend("isValidCompanyName", function (str) {
369    return str && str.trim && str.trim().length >= 2 && str.trim().length <= 250 && !str.match(/[<>]+/);
370});
371
372validator.extend("isValidCompanyBlurb", function (str) {
373    return str && str.trim && str.trim().length >= 2 && !str.match(/[<>]+/);
374});
375
376validator.extend("isPassword", function (str) {
377    return (str && str.length && str.length >= 6 && str.length <= 32 && /^[a-zA-Z0-9\!\@\#\$\%\^\&\*\(\)]+$/.test(str));
378});
379
380validator.extend("isValidName", function (str) {
381    return str && str.trim && str.trim().length >= 1 && !str.match(/[<>]+/);
382});
383
384validator.extend("isValidUserId", function( id )  {
385    if(typeof(id) == 'string')
386        if( !validator.REGEX_NUMID.test(id) )
387            return false;
388        else
389            id = parseInt(id);
390
391    return (id && typeof(id) == 'number' && id > 0);
392});
393
394validator.extend("isValidStreetAddress",function (str) {
395    return str && str.length && /[A-Za-z0-9'\.\-\s\,]{4,40}/.test(str) && !str.match(/[<>]+/);
396});
397
398validator.extend("isValidPhone",function (str) {
399    return str && str.trim && str.trim().length > 7;
400});
401
402validator.extend("isValidPostalCode",function (str) {
403    return str && str.length && /^[A-Za-z0-9'\.\-\s\,]{4,15}$/.test(str) && !str.match(/[<>]+/);
404});
405
406validator.extend("isValidTopicText", function (str) {
407    return str && str.trim && str.trim().length >= 2 && str.trim().length <= 250 && !str.match(/[<>]+/);
408});
409

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.