title: Email & Phone Validation in Swift
body: <p>i am using the following code for phone number validation. But i am getting the following error. I cant able to proceed further. Help us to take it forward.</p>
  
  <pre><code>class PhoneNumberValidation: Validation {
      let PHONE_REGEX = "^\\d{3}-\\d{3}-\\d{4}$"
  
      func validate(value: String) -&gt; (Bool, ValidationErrorType) {
          if let phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX) {
              if phoneTest.evaluateWithObject(value) {
                  return (true, .NoError)
              }
              return (false, .PhoneNumber)
          }
          return (false, .PhoneNumber)
      }
  }
  </code></pre>
  
  <p>Error : swift:15:28: Bound value in a conditional binding must be of Optional type</p>