Question: Create a JavaScript program named email _ validator.js for validating email addresses using a regular expression. Implement an EmailValidator class with the following functionalities :

Create a JavaScript program named email_ validator.js for validating email addresses using a regular expression. Implement an EmailValidator class with the following functionalities
:1. Constructor:- No parameters required.
2. validateEmail Method:- Parameters: 'email' (string)- Returns a boolean indicating whether the provided email address is valid according to the specified regular expression rules.The regular expression rules for a valid email address are as follows:- The email address must contain exactly one \"@\" symbol.- The \"@\" symbol must not be the first or last character in the email address.- The part before the \"@\" symbol must contain at least one character, consisting of letters, digits, dots (.), hyphens (-), or underscores (_).- The part after the \"@\" symbol must contain at least one dot (.) followed by two or more characters.Export the class as a module and import it into a class called emailtester.js. Implement a simple program in this file using the test code provided.
Sample Usage:javascript// Import the EmailValidator classconst EmailValidator = require('./EmailValidator );// Create an instance of EmailValidatorconst validator = new EmailValidator);// Validate email addressesconsole.log/validator.validateEmail(\"john.doe@example.com\")); // Output: true console.log(validator.validateEmail\"invalid-email@example\"); // Output: false console.log(validator.validateEmail\"email@example.co.uk\")); // Output: true console.log/validator.validateEmail\"another_email@domain\")); // Output: false

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!