@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.
25 lines (24 loc) • 738 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.alphanumeric = void 0;
var _constants = require("@inkline/inkline/validation/validators/constants");
const alphanumeric = (rawValue, options) => {
const locale = options.locale || "en-US";
const process = v => {
let value = String(v);
if (options.allowDashes) {
value = value.replace(/-/g, "");
}
if (options.allowSpaces) {
value = value.replace(/ /g, "");
}
return value;
};
if (rawValue?.constructor === Array) {
return rawValue.every(v => _constants.alphanumeric[locale].test(process(v)));
}
return _constants.alphanumeric[locale].test(process(rawValue));
};
exports.alphanumeric = alphanumeric;