digitalmars.D.learn - Email validation
- Vino (10/10) Nov 28 2017 Hi All,
- Rene Zwanenburg (3/4) Nov 28 2017 You can do this easily using the std.net.isemail module:
- Vino (7/11) Nov 28 2017 Hi Rene,
- Mike Wey (13/27) Nov 28 2017 isEmail returns a struct with the status of the check.
- codephantom (2/4) Nov 28 2017 I don't believe MX validation (checkDns) is implemented yet.
- codephantom (10/14) Nov 28 2017 btw... yes documentation is an acknowledged issue with regards to
- codephantom (25/35) Nov 28 2017 test/improve it yourself. but you get the idea....
- codephantom (22/32) Nov 28 2017 Here's another nice option I just found.
Hi All, Can you please provide me some example on who to validate an email address as the document dose not have an example for the same Ex: vino.bheeman hotmail.com Conditions : The domain should contain only "hotmail.com" The email address should contain the symbol " " From, Vino.B
Nov 28 2017
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:Hi All,You can do this easily using the std.net.isemail module: https://dlang.org/phobos/std_net_isemail.html
Nov 28 2017
On Tuesday, 28 November 2017 at 18:51:50 UTC, Rene Zwanenburg wrote:On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:Hi Rene, Can you provide me a example, as the link does not have any examples. From, Vino.BHi All,You can do this easily using the std.net.isemail module: https://dlang.org/phobos/std_net_isemail.html
Nov 28 2017
On 28-11-17 20:32, Vino wrote:On Tuesday, 28 November 2017 at 18:51:50 UTC, Rene Zwanenburg wrote:isEmail returns a struct with the status of the check. You can use the valid and domainPart to check if it's a valid email address for the hotmail domain. isMail only checks the formatting of the email address and optionally if the domain has a MX record. ``` auto e = isEmail("vino.bheeman hotmail.com"); if ( e.valid && e.domainPart == "hotmail.com" ) ... ``` -- Mike WeyOn Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:Hi Rene, Can you provide me a example, as the link does not have any examples. From, Vino.BHi All,You can do this easily using the std.net.isemail module: https://dlang.org/phobos/std_net_isemail.html
Nov 28 2017
On Tuesday, 28 November 2017 at 22:42:27 UTC, Mike Wey wrote:isMail only checks the formatting of the email address and optionally if the domain has a MX record.I don't believe MX validation (checkDns) is implemented yet.
Nov 28 2017
On Tuesday, 28 November 2017 at 19:32:40 UTC, Vino wrote:Can you provide me a example, as the link does not have any examples. From, Vino.Bbtw... yes documentation is an acknowledged issue with regards to phobos...but..that aside...it can also be useful (and wise) to look at the unit tests in the source code. I'm not sure that simply calling something you don't know anything about is such a good idea these days ;-) ...fortunately, we have access to the source - which gets installed with dmd. or you can find it on github. https://github.com/dlang/phobos
Nov 28 2017
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:Hi All, Can you please provide me some example on who to validate an email address as the document dose not have an example for the same Ex: vino.bheeman hotmail.com Conditions : The domain should contain only "hotmail.com" The email address should contain the symbol " " From, Vino.Btest/improve it yourself. but you get the idea.... // ---------------------- module test; import std.stdio; import std.algorithm; /+ CONDITIONS: - The domain should contain only "hotmail.com" - The email address should contain the symbol " " +/ void main() { string domainRequired = "hotmail.com"; string emailAddress = "vino.bheeman hotmail.com"; auto checkDomain = findSplitAfter(emailAddress, " "); // requires import std.algorithm //writeln(checkDomain); // Tuple!(string, string)("vino.bheeman ", "hotmail.com") if (checkDomain[1] == domainRequired) writeln("domain ok"); else writeln("invalid domain"); } // ----------------------
Nov 28 2017
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:Hi All, Can you please provide me some example on who to validate an email address as the document dose not have an example for the same Ex: vino.bheeman hotmail.com Conditions : The domain should contain only "hotmail.com" The email address should contain the symbol " " From, Vino.BHere's another nice option I just found. Interestingly, I had to disable Avast antivirus, otherwise when I compile it, Avast thinks the exectuable is 'suspicous' and prevents any further access to it...wtf? // --------------------- module test; import std.stdio; import std.algorithm; /+ CONDITIONS: - The domain should contain only "hotmail.com" - The email address should contain the symbol " " +/ void main() { string domainRequired = " hotmail.com"; string emailAddress = "vino.bheeman hotmail.com"; emailAddress.endsWith(domainRequired) ? writeln("domain ok") : writeln("invalid domain"); } // --------------------
Nov 28 2017
On Wednesday, 29 November 2017 at 03:49:56 UTC, codephantom wrote:string domainRequired = " hotmail.com"; string emailAddress = "vino.bheeman hotmail.com"; emailAddress.endsWith(domainRequired) ? writeln("domain ok") : writeln("invalid domain");Also you need check that only one used.
Nov 28 2017
On Wednesday, 29 November 2017 at 05:22:34 UTC, Dmitry wrote:On Wednesday, 29 November 2017 at 03:49:56 UTC, codephantom wrote:Hi All, Thank you, the above code worked. From, Vino.Bstring domainRequired = " hotmail.com"; string emailAddress = "vino.bheeman hotmail.com"; emailAddress.endsWith(domainRequired) ? writeln("domain ok") : writeln("invalid domain");Also you need check that only one used.
Nov 28 2017