         
     }
     
+    // MARK: - Data validation
+    func validateData() -> Bool {
+        var sourceDict:Dictionary<String, String>
+        if !isShippingAddress {
+            // Check email address too...
+            if emailAddress == nil {
+                // no email - warn and give up!
+                AlertDialog.showAlert("Error", message: "No email address entered! Please enter a valid email and try again.", viewController: self)
+                
+                return false
+            }
+            
+            sourceDict = billingDictionary!
+        } else {
+            sourceDict = shippingDictionary!
+        }
+        
+        let requiredFields = [contactFirstNameFieldIdentifier, contactLastNameFieldIdentifier, address1FieldIdentifier, cityFieldIdentifier, stateFieldIdentifier, countryFieldIdentifier, postcodeFieldIdentifier]
+        
+        var valid = true
+        
+        for field in requiredFields {
+            var valuePresent = false
+            var lengthValid = false
+            
+            if let value = sourceDict[field] {
+                // success
+                valuePresent = true
+                var stringValue = value as String
+                if count(stringValue) < 1 {
+                    // The string's empty!
+                    lengthValid = true
+                }
+                continue
+            } else {
+                valuePresent = false
+            }
+            
+            if !valuePresent || !lengthValid {
+                // Warn user!
+                valid = false
+                
+                var userPresentableName = field.stringByReplacingOccurrencesOfString("_", withString: " ")
+                userPresentableName = userPresentableName.capitalizedString
+                
+                AlertDialog.showAlert("Error", message: "\(userPresentableName) is not present", viewController: self)
+            }
+        }
+        
+        return valid
+        
+    }
+    
+    // MARK: - Data processing
+
     // A function that gets all of the address field values and returns a billing or shipping address dictionary suitable to pass to the Moltin API.
     func getAddressDict() -> Dictionary<String, String> {
         // TODO: Implement

        self.tableView.reloadData()
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // MARK: - Table view data source
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {

        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        
        // If the user tapped on the Continue button, continue!
        if ((indexPath.row == contactFieldsArray.count && isShippingAddress) || (indexPath.row == contactFieldsArray.count + 1 && !isShippingAddress)) {
            continueButtonTapped()
            return
        }

