CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-eval

Babel plugin that transforms eval() calls containing string literals by parsing and compiling the string content at transform time

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-4/

Email Validator with Unicode Support

Build an email validation library that leverages modern regular expression features to handle international email addresses and extract meaningful information from them.

Requirements

Your task is to implement an email validator that:

  1. Validates email addresses using Unicode property escapes to support international characters (letters from any script)
  2. Extracts the username and domain parts using named capture groups
  3. Supports case-insensitive matching

The validator should handle:

  • International usernames containing Unicode letters (e.g., Arabic, Chinese, Cyrillic scripts)
  • Standard ASCII email addresses
  • International domain names with Unicode characters
  • Case-insensitive validation (e.g., "User@Example.COM" should be valid)

Test Cases

  • Validates a standard ASCII email address "user@example.com" @test
  • Validates an international email with Unicode letters in username "用户@example.com" @test
  • Validates an email with Cyrillic characters "пользователь@домен.рф" @test
  • Extracts username and domain from "john.doe@company.org" as {username: "john.doe", domain: "company.org"} @test
  • Handles case-insensitive matching for "Admin@EXAMPLE.COM" @test
  • Rejects invalid email without @ symbol "invalidemail.com" @test

Implementation

@generates

API

/**
 * Validates an email address supporting international Unicode characters.
 *
 * @param {string} email - The email address to validate
 * @returns {boolean} True if the email is valid, false otherwise
 */
function validateEmail(email) {
  // IMPLEMENTATION HERE
}

/**
 * Extracts the username and domain parts from a valid email address.
 *
 * @param {string} email - The email address to parse
 * @returns {Object|null} An object with 'username' and 'domain' properties, or null if invalid
 */
function extractEmailParts(email) {
  // IMPLEMENTATION HERE
}

module.exports = {
  validateEmail,
  extractEmailParts
};

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the core Babel transformation API for compiling modern JavaScript features including advanced regular expressions.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-eval

tile.json