You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vibe.utils.validation.validateEmail tests the results of std.net.isemail.isEmail like this:
return isEmail(str) != EmailStatusCode.valid;
However, isEmail returns EmailStatus, not EmailStatusCode. Incidentally, EmailStatus aliases self to a bool property valid(), which allows the code above to compile. But the logic is reversed, since EmailStatusCode.valid == 0, although isEmail(str) == false when the e-mail is invalid.
Paired with Phobos fixes between versions, this leads to further inconsistencies at run time.
For example, with dmd 2.071.1 (when there was an issue in Phobos):
auto result = isEmail("[email protected]");
/*
result == EmailStatus
{
valid: false
localPart: a
domainPart: b.c
statusCode: error
}
*/
auto err = appender!string();
auto vibeResult = validateEmail(err, "[email protected]");
/*
vibeResult == true
*/
Even though isEmail() (incorrectly) returned an invalid status, vibe treats it as valid.
And with current dmd nightly:
auto result = isEmail("[email protected]");
/*
result == EmailStatus
{
valid: true
localPart: a
domainPart: b.c
statusCode: valid
}
*/
auto err = appender!string();
auto vibeResult = validateEmail(err, "[email protected]");
/*
vibeResult == false
err.data == "The email address is invalid."
*/
Vice-versa, isEmail() now correctly returns a valid status, but vibe treats it as invalid.
The text was updated successfully, but these errors were encountered:
Note: Phobos issue mentioned above holds for Phobos included with dmd 2.071.2 as well. The proposed fix would effectively break validateEmail() for anyone not using nightly dmd/Phobos builds.
vibe.utils.validation.validateEmail tests the results of std.net.isemail.isEmail like this:
However, isEmail returns EmailStatus, not EmailStatusCode. Incidentally, EmailStatus aliases self to a bool property valid(), which allows the code above to compile. But the logic is reversed, since EmailStatusCode.valid == 0, although isEmail(str) == false when the e-mail is invalid.
Paired with Phobos fixes between versions, this leads to further inconsistencies at run time.
For example, with dmd 2.071.1 (when there was an issue in Phobos):
Even though isEmail() (incorrectly) returned an invalid status, vibe treats it as valid.
And with current dmd nightly:
Vice-versa, isEmail() now correctly returns a valid status, but vibe treats it as invalid.
The text was updated successfully, but these errors were encountered: