@inkline/inkline
Version:
Inkline is the intuitive UI Components library that gives you a developer-friendly foundation for building high-quality, accessible, and customizable Vue.js 3 Design Systems.
17 lines (16 loc) • 506 B
JavaScript
export const maxLength = (value, options) => {
if (typeof options.value === "undefined") {
console.error('The "value" option must be specified for "maxLength" validator.');
return true;
}
if (typeof value === "undefined" || value === null) {
return false;
}
if (value.constructor === Array) {
return value.length <= options.value;
}
if (typeof value === "object") {
return Object.keys(value).length <= options.value;
}
return String(value).length <= options.value;
};