On 2011-03-23 11:46, Nick Sabalausky wrote:
"Jacob Carlborg"<d...@me.com>  wrote in message
news:imcgim$1sk4$1...@digitalmars.com...
On 2011-03-22 23:21, dsimcha wrote:

3. What are EmailStatusCode.On and EmailStatusCode.Off?

I had some problem figuring out how I wanted to solve this. In the PHP
version the function takes a parameter, errorLevel, indicating what error
level you want. Any status code above will be returned as-is and status
codes below will be returned as "valid". In addition to this you can pass
"true" or "false". If "true", any status code except "valid" will be
considered invalid.  If "false", the function just returns "true" or
"false" rather than an integer error or warning.

The problem I had was that since D is statically typed you cannot mix
integer and boolean values in one parameter, specially not if the integer
parameter is an enum. Since I wanted to be able to pass both a
EmailStatusCode value as errorLevel and "true" and "false" I added
EmailStatusCode.On and EmailStatusCode.Off representing "true" and
"false". I should document this.


In that case, I would suggest:

- Rename EmailStatusCode.On to EmailStatusCode.Any

- Remove EmailStatusCode.Off, and split isEmail into two overloads:

EmailStatus isEmail(T)(const(T)[] email, bool checkDNS, EmailStatusCode
errorLevel);

and

bool isEmail(T)(const(T)[] email, bool checkDNS = false);

That second one would be the equivalent of passing "false" into the PHP
version.

That might be a good idea.

--
/Jacob Carlborg

Reply via email to