const isEmailValidator = require('validator').isEmail;
const isEmptyValidator = require('validator').isEmpty;
isEmailValidator('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a5aba687a5aba6e9a4a8aa">[email protected]</a>');
Is this the format you were thinking of? Your original approach is also valid:
import {isEmail, isEmpty} from 'validator';
isEmail('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c1e101d3c1e101d521f1311">[email protected]</a>');
Additional clarification: The validator.js library exports an object with each function as shown here https://github.com/chriso/validator.js/blob/master/src/index.js. You can import all functions using
import validator from 'validator'
or selectively import specific properties using destructuring.