UNPKG

voca

Version:

The ultimate JavaScript string library

33 lines (29 loc) 857 B
import './internal/is_nil.js'; import './is_string.js'; import { c as coerceToString } from './internal/coerce_to_string.js'; import './internal/const.js'; import { c as REGEXP_ALPHA_DIGIT } from './internal/const_extended.js'; /** * Checks whether `subject` contains only alpha and digit characters. * * @function isAlphaDigit * @static * @since 1.0.0 * @memberOf Query * @param {string} [subject=''] The string to verify. * @return {boolean} Returns `true` if `subject` contains only alpha and digit characters or `false` otherwise. * @example * v.isAlphaDigit('year2020'); * // => true * * v.isAlphaDigit('1448'); * // => true * * v.isAlphaDigit('40-20'); * // => false */ function isAlphaDigit(subject) { var subjectString = coerceToString(subject); return REGEXP_ALPHA_DIGIT.test(subjectString); } export default isAlphaDigit;