luhn-generator
Version:
A generator of numbers that passes the validation of Luhn algorithm or Luhn formula, also known as the 'modulus 10' or 'mod 10' algorithm
23 lines (20 loc) • 758 B
JavaScript
import standards from '../../standards';
import isUnsupportedRole from './is-unsupported-role';
/**
* Check if a given role is valid
* @method isValidRole
* @memberof axe.commons.aria
* @instance
* @param {String} role The role to check
* @param {Object} options Use `allowAbstract` if you want abstracts, and `flagUnsupported: true` to report unsupported roles
* @return {Boolean}
*/
function isValidRole(role, { allowAbstract, flagUnsupported = false } = {}) {
const roleDefinition = standards.ariaRoles[role];
const isRoleUnsupported = isUnsupportedRole(role);
if (!roleDefinition || (flagUnsupported && isRoleUnsupported)) {
return false;
}
return allowAbstract ? true : roleDefinition.type !== 'abstract';
}
export default isValidRole;