| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 37x 34x 34x 34x 22x 15x | import global from '../../global';
/**
* @function isValid
* @description Test if a given string match the given regular expression
*
* @param {String} string String to test
* @param {String} regexpValue regular expression to test
* @returns Boolean
*/
export default (string, regexpValue) => {
if (string && regexpValue) {
try {
const regexp = new RegExp(regexpValue);
if (regexp.test(string)) {
return true;
}
} catch (error) {
global.logger.warn(error.message);
}
}
return false;
};
|