title: Swift: Multiple conditions in IF statement
body: <p>I'm currently trying to validate a sign up page using an if statement with multiple conditions.</p>
  
  <p>At the same time, I want to validate the email address with a correct email format. </p>
  
  <p>Below is each field should essentially be checked. </p>
  
  <pre><code>@IBAction func createAccountButton(_ sender: Any) {
  
      //check if textfields are empty and display alert
      let providedEmailAddress = emailTextField.text
      let isEmailAddressValid = isValidEmailAddress(emailAddressString: providedEmailAddress!)
  
  
      if ( isEmailAddressValid || (firstNameTextField.text?.isEmpty)! || (lastNameTextField.text?.isEmpty)! || (usernameTextField.text?.isEmpty)! || (phoneNumberTextField.text?.isEmpty)! || (passwordTextField.text?.isEmpty)!) {
          let alertViewController = SCLAlertView().showInfo("Failed to create account", subTitle: "One or more fields are empty, please check and try again.")
      } else {
          SVProgressHUD.show(withStatus: "Creating account...")
          SVProgressHUD.dismiss(withDelay: 4)
      }
  }
  </code></pre>
  
  <p>The variable <code>isEmailAddressValid</code> is linked to this function I found on <a href="http://swiftdeveloperblog.com/code-examples/validate-email-address-code-example-in-swift/" rel="nofollow noreferrer">this site</a>.</p>
  
  <pre><code>// Check if email address entered is of the valid format
      func isValidEmailAddress(emailAddressString: String) -&gt; Bool {
  
          var returnValue = true
          let emailRegEx = "[A-Z0-9a-z.-_]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,3}"
  
          do {
              let regex = try NSRegularExpression(pattern: emailRegEx)
              let nsString = emailAddressString as NSString
              let results = regex.matches(in: emailAddressString, range: NSRange(location: 0, length: nsString.length))
  
              if results.count == 0
              {
                  returnValue = false
              }
  
          } catch let error as NSError {
              print("invalid regex: \(error.localizedDescription)")
              returnValue = false
          }
  
          return  returnValue
      }
  </code></pre>
  
  <p>However, when testing I realised when I enter a value in each field except the <code>emailTextfield.text</code> and click to create an account, the <code>else</code> part of the statement is executed.</p>
  
  <p>Moreover when all fields have a value, I would assume the <code>else</code> part of the statement WILL execute, but the 'failed to create an account' alert is displayed instead.</p>
  
  <p>What am I doing wrong and what needs to be changed?</p>