Node.js examples for Date:Date Calculation
Validate value range
Validator.validateRange = function(value, min, max) { (min === undefined) ? min = 0: min = min; (max === undefined) ? max = 100: max = max; if ((min >= max || max <= min) && (max !== 0)) { throw "Validator : When calling validateRange min is the minimum and max should be the maximum."; }/*from w ww . j a va 2 s . c o m*/ var ivalue = value; if (min !== 0 && max !== 0) { if (ivalue > min && ivalue < max) { return true; } else { return false; } return false; } if (min === 0 && max !== 0) { if (ivalue < max) { return true; } else { return false; } return false; } if (min !== 0 && max === 0) { if (ivalue > min) { return true; } else { return false; } return false; } return true; };