Source/NFX/Parsing/DataEntryUtils.cs
/// <summary>
/// Returns true if the value is a valid non-null/empty email address
/// </summary>
Returns true if the value is a valid non-null/empty email address
Returns true if the value is a valid non - null / empty email address
public static bool CheckEMail(string email)
    {
      if (email.IsNullOrWhiteSpace()) return false;
      var lastPos = email.Length - 1;
      var atPos = email.IndexOf('@');
      if (atPos <= 0 || atPos == lastPos)
        return false;
      char c;
      var prevIsDot = false;
      var end = atPos - 1;
      for (int i = 0; i <= end; i++)
      {
        c = email[i];
        if (i == 0 || i == end)
        {
          if (!IsValidEMailLocalPartChar(c)) return false;
          continue;
        }
        if (c == '.')
        {
          if (prevIsDot) return false;
          prevIsDot = true;
        }
        else
        {
          if (!IsValidEMailLocalPartChar(c)) return false;
          prevIsDot = false;
        }
      }
      var prevIsHyphen = false;
      prevIsDot = false;
      var start = atPos + 1;
      end = lastPos;
      for (int i = start; i <= end; i++)
      {
        c = email[i];
        if (i == start || i == end)
        {
          if (!Char.IsLetterOrDigit(c)) return false;
          continue;
        }
        if (c == '.')
        {
          if (prevIsDot || prevIsHyphen) return false;
          prevIsDot = true;
          continue;
        }
        if (c == '-')
        {
          if (prevIsDot) return false;
          prevIsHyphen = true;
          continue;
        }
        if (!Char.IsLetterOrDigit(c)) return false;
        prevIsDot = false;
        prevIsHyphen = false;
      }
      return true;
    }
public static bool CheckEMail ( string email ) { if ( email . IsNullOrWhiteSpace ( ) ) return false ; var lastPos = email . Length - 1 ; var atPos = email . IndexOf ( ' ' ) ; if ( atPos <= 0 || atPos == lastPos ) return false ; char c ; var prevIsDot = false ; var end = atPos - 1 ; for ( int i = 0 ; i <= end ; i ++ ) { c = email [ i ] ; if ( i == 0 || i == end ) { if ( ! IsValidEMailLocalPartChar ( c ) ) return false ; continue ; } if ( c == ' ' ) { if ( prevIsDot ) return false ; prevIsDot = true ; } else { if ( ! IsValidEMailLocalPartChar ( c ) ) return false ; prevIsDot = false ; } } var prevIsHyphen = false ; prevIsDot = false ; var start = atPos + 1 ; end = lastPos ; for ( int i = start ; i <= end ; i ++ ) { c = email [ i ] ; if ( i == start || i == end ) { if ( ! Char . IsLetterOrDigit ( c ) ) return false ; continue ; } if ( c == ' ' ) { if ( prevIsDot || prevIsHyphen ) return false ; prevIsDot = true ; continue ; } if ( c == ' ' ) { if ( prevIsDot ) return false ; prevIsHyphen = true ; continue ; } if ( ! Char . IsLetterOrDigit ( c ) ) return false ; prevIsDot = false ; prevIsHyphen = false ; } return true ; }
Returns true if the value is a valid non-null/empty email address
Returns true if the value is a valid non - null / empty email address
// local part // domain part
email
string