[phobos] isemail error handling

Jonathan M Davis jmdavisProg at gmx.com
Sat Mar 5 13:49:46 PST 2011


On Saturday 05 March 2011 03:07:29 Jacob Carlborg wrote:
> The PHP version returns "true", "false" or a code indicating why the email
> address isn't valid. In addition to that it has an out parameter, an
> array, containing among other things the local and the domain part of the
> address. I was thinking that I either keep it like that, with an out
> parameter, or return a struct with the information.
> 
> If I return a struct I was thinking it would contain the following fields:
> 
> bool valid;
> string local;
> string domain;
> int statusCode/reasonCode;

That sounds like a good solution. You could even add the string function for the 
reason code that Walter suggested to the struct itself. But a struct like that 
isn't all that large anyway. Returning a struct which implicitly casts to bool 
sounds like a solid solution though.

- Jonathan M Davis


More information about the phobos mailing list