validatorshield
Version:
Universal validation (frontend + backend) with TypeScript. Includes common rules and Sequelize-backed async rules (unique, exists).
15 lines (14 loc) • 519 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.between = between;
function between(value, _ctx, min, max) {
const minNum = parseFloat(min);
const maxNum = parseFloat(max);
if (typeof value === 'number')
return value >= minNum && value <= maxNum;
if (typeof value === 'string')
return value.length >= minNum && value.length <= maxNum;
if (Array.isArray(value))
return value.length >= minNum && value.length <= maxNum;
return false;
}