Docly Developers
Function Updated 23 Oct 2026

isEmail(value)

Validates if a string is an email address, using the .NET MailAddress parser.

The check is lenient: it also accepts a display-name form such as "Test Test" test@test.com and an address without a top-level domain such as x@bug. Add your own check if you need a stricter rule. Values that are not text, and empty text, give false.

Parameters

valueobjectrequired

Value to validate

Returns

True if validates as email.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{

    // Array with email addresses for testing
    const emails = [
        "Not an email",
        "test@mail.com",
        "tes t@mail.com",
        "@bug.com",
        "x@bug",
        "",
        null,
        "\"Test Test\" <test@test.com>"
    ];
    
    // Loop through array and test each email
    emails.forEach((email, index) => {
        const isValid = docly.isEmail(email);
        const status = isValid ? "✓ VALID" : "✗ ERROR";
        write(`Test ${index + 1}: ${status} - "${email}" => ${isValid}\n`);
    });
}#