isEmail(value) Last updated: 22. Aug 2025
Validates if string is an email.
Parameters
Name | Type | Description |
---|---|---|
value | object | Value to validate |
Returns
True if validates as email.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#{
// 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`);
});
}#
Output
The #JS code above produces the output shown below:Test 1: ✗ ERROR - "Not an email" => False
Test 2: ✓ VALID - "test@mail.com" => True
Test 3: ✓ VALID - "tes t@mail.com" => True
Test 4: ✗ ERROR - "@bug.com" => False
Test 5: ✓ VALID - "x@bug" => True
Test 6: ✗ ERROR - "" => False
Test 7: ✗ ERROR - "" => False
Test 8: ✓ VALID - ""Test Test" <test@test.com>" => True