livr
Version:
Lightweight validator supporting Language Independent Validation Rules Specification
14 lines (11 loc) • 371 B
JavaScript
const util = require('../../util');
function max_length(maxLength) {
return (value, params, outputArr) => {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
value += '';
if (value.length > maxLength) return 'TOO_LONG';
outputArr.push(value);
};
}
module.exports = max_length;