C# Class Tickster.Validation.Rfc822AddressValidator

A high-performance email address validator that validates most email address formats specified in RFC 822. Outperforms several non-trivial (interpreted) regular expression based validation methods.

The Validation methods are thread safe in the sense that they do not share any validation state but the configuration properties of the validator may affect the validator in a way that causes invalid addresses to be considered valid (and vice-versa) if they are modified while an address is being validated.

Instantiation is cheap after first init (when the static constructor has completed) so there's really no need share validators across threads but as long as you don't touch the config properties after instantiation you should be safe.

This class doesn't currently support the full address token (mailbox/group). It only supports the addr-spec (local-part "@" domain) and has no support for specifying routes

Mostra file Open project: tickster/Tickster.Utilities

Public Methods

Method Description
Validate ( string emailAddress ) : bool

RFC822 internet text message (email) address validation.

Private Methods

Method Description
InitChars ( ) : void
InitValidTopLevelDomains ( ) : void
IsKnownTopLevelDomain ( string tld, string &errorMessage ) : bool
IsValidAtom ( string atom, string &errorMessage ) : bool
IsValidDomain ( string domain, string &errorMessage ) : bool
IsValidDomainLiteral ( string domainLiteral, string &errorMessage ) : bool
IsValidLocalPart ( string localPart, string &errorMessage ) : bool
IsValidQuotedString ( string qs, string &errorMessage ) : bool
IsValidQuotedStringContents ( string content, string &errorMessage ) : bool
IsValidSubDomain ( string subDomain, string &errorMessage, bool rfc822Strict ) : bool
IsValidWord ( string word, string &errorMessage ) : bool
Rfc822AddressValidator ( ) : System

Initializes static members of the Rfc822AddressValidator class.

Static constructors in .net are guaranteed to be thread safe and only runs once

Validate ( string emailAddress, string &errorMessage ) : bool

Method Details

Validate() public method

RFC822 internet text message (email) address validation.
public Validate ( string emailAddress ) : bool
emailAddress string The address to validate
return bool