Updating for swift 1.2
This commit is contained in:
parent
ae514e2c61
commit
ff25465d93
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7518.3"/>
|
||||
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
</dependencies>
|
||||
|
|
@ -21,13 +21,13 @@
|
|||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Full Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="khR-OB-bgx">
|
||||
<rect key="frame" x="0.0" y="-21" width="42" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Email" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MOa-Y4-nDo">
|
||||
<rect key="frame" x="0.0" y="-21" width="42" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="darth@deathstar.com" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ibf-gq-p2X">
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Phone" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gjm-Ww-AYk">
|
||||
<rect key="frame" x="0.0" y="-21" width="42" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="XXX-XXX-XXXX" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qLN-YJ-gUx">
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Zipcode" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2or-KE-2NU">
|
||||
<rect key="frame" x="0.0" y="-21" width="42" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="XXXXX" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Zu1-QS-1Yk">
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Email Confirm" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bLY-f8-5zf">
|
||||
<rect key="frame" x="0.0" y="-21" width="42" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="darth@deathstar.com" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="O9u-O8-mPB">
|
||||
|
|
@ -153,18 +153,18 @@
|
|||
<nil key="highlightedColor"/>
|
||||
<variation key="default">
|
||||
<mask key="constraints">
|
||||
<exclude reference="SdK-o6-MXe"/>
|
||||
<exclude reference="bi4-dv-zcg"/>
|
||||
<exclude reference="fjW-er-ghM"/>
|
||||
<exclude reference="hpm-mc-xeq"/>
|
||||
<exclude reference="bi4-dv-zcg"/>
|
||||
<exclude reference="SdK-o6-MXe"/>
|
||||
</mask>
|
||||
</variation>
|
||||
<variation key="heightClass=regular-widthClass=compact">
|
||||
<mask key="constraints">
|
||||
<include reference="SdK-o6-MXe"/>
|
||||
<include reference="bi4-dv-zcg"/>
|
||||
<include reference="fjW-er-ghM"/>
|
||||
<include reference="hpm-mc-xeq"/>
|
||||
<include reference="bi4-dv-zcg"/>
|
||||
<include reference="SdK-o6-MXe"/>
|
||||
</mask>
|
||||
</variation>
|
||||
</label>
|
||||
|
|
@ -289,46 +289,46 @@
|
|||
<exclude reference="3uK-Qz-rLB"/>
|
||||
</mask>
|
||||
<mask key="constraints">
|
||||
<exclude reference="bud-iX-j0f"/>
|
||||
<exclude reference="ggx-3K-K1L"/>
|
||||
<exclude reference="A7P-r9-8FC"/>
|
||||
<exclude reference="PaQ-6i-9mo"/>
|
||||
<exclude reference="Ion-9h-zfc"/>
|
||||
<exclude reference="VDP-DY-jUh"/>
|
||||
<exclude reference="rRl-bj-wIm"/>
|
||||
<exclude reference="t8X-0Q-RPA"/>
|
||||
<exclude reference="55u-lk-Vl8"/>
|
||||
<exclude reference="OdB-kn-E8t"/>
|
||||
<exclude reference="7Ce-Df-SWx"/>
|
||||
<exclude reference="PEI-qV-ay9"/>
|
||||
<exclude reference="cNA-Yf-qTv"/>
|
||||
<exclude reference="LFO-jd-axU"/>
|
||||
<exclude reference="wny-JX-bf3"/>
|
||||
<exclude reference="6Yc-1K-Ngl"/>
|
||||
<exclude reference="h2v-wj-aTe"/>
|
||||
<exclude reference="DtP-3P-vpf"/>
|
||||
<exclude reference="T1M-HW-h60"/>
|
||||
<exclude reference="ds9-gC-21F"/>
|
||||
<exclude reference="htl-Vj-x3w"/>
|
||||
<exclude reference="B28-e9-frX"/>
|
||||
<exclude reference="Egg-Ya-137"/>
|
||||
<exclude reference="eAd-Wu-obj"/>
|
||||
<exclude reference="k2e-YN-zp4"/>
|
||||
<exclude reference="qWu-f4-OGv"/>
|
||||
<exclude reference="sh3-oU-dEE"/>
|
||||
<exclude reference="1CI-nz-vpx"/>
|
||||
<exclude reference="6vG-Jg-fmU"/>
|
||||
<exclude reference="H9S-E2-xEW"/>
|
||||
<exclude reference="VWf-RY-YhF"/>
|
||||
<exclude reference="X7j-Pp-Rbz"/>
|
||||
<exclude reference="aeN-FP-LX6"/>
|
||||
<exclude reference="55u-lk-Vl8"/>
|
||||
<exclude reference="OdB-kn-E8t"/>
|
||||
<exclude reference="7J7-45-P5G"/>
|
||||
<exclude reference="hpD-Om-vt4"/>
|
||||
<exclude reference="qWu-f4-OGv"/>
|
||||
<exclude reference="sh3-oU-dEE"/>
|
||||
<exclude reference="DtP-3P-vpf"/>
|
||||
<exclude reference="T1M-HW-h60"/>
|
||||
<exclude reference="ds9-gC-21F"/>
|
||||
<exclude reference="htl-Vj-x3w"/>
|
||||
<exclude reference="LFO-jd-axU"/>
|
||||
<exclude reference="wny-JX-bf3"/>
|
||||
<exclude reference="PEI-qV-ay9"/>
|
||||
<exclude reference="cNA-Yf-qTv"/>
|
||||
<exclude reference="bud-iX-j0f"/>
|
||||
<exclude reference="ggx-3K-K1L"/>
|
||||
<exclude reference="9zK-3U-gYU"/>
|
||||
<exclude reference="60N-Dv-oSw"/>
|
||||
<exclude reference="K5d-es-d8h"/>
|
||||
<exclude reference="VDe-WO-sJU"/>
|
||||
<exclude reference="d08-t5-VT0"/>
|
||||
<exclude reference="7Ce-Df-SWx"/>
|
||||
<exclude reference="A7P-r9-8FC"/>
|
||||
<exclude reference="PaQ-6i-9mo"/>
|
||||
<exclude reference="B28-e9-frX"/>
|
||||
<exclude reference="Egg-Ya-137"/>
|
||||
<exclude reference="eAd-Wu-obj"/>
|
||||
<exclude reference="k2e-YN-zp4"/>
|
||||
<exclude reference="9zK-3U-gYU"/>
|
||||
<exclude reference="7J7-45-P5G"/>
|
||||
<exclude reference="hpD-Om-vt4"/>
|
||||
<exclude reference="1Qc-NM-cha"/>
|
||||
<exclude reference="7PG-72-xfy"/>
|
||||
<exclude reference="M9f-Bp-Gbg"/>
|
||||
|
|
@ -354,46 +354,46 @@
|
|||
<include reference="3uK-Qz-rLB"/>
|
||||
</mask>
|
||||
<mask key="constraints">
|
||||
<include reference="bud-iX-j0f"/>
|
||||
<include reference="ggx-3K-K1L"/>
|
||||
<include reference="A7P-r9-8FC"/>
|
||||
<include reference="PaQ-6i-9mo"/>
|
||||
<include reference="Ion-9h-zfc"/>
|
||||
<include reference="VDP-DY-jUh"/>
|
||||
<include reference="rRl-bj-wIm"/>
|
||||
<include reference="t8X-0Q-RPA"/>
|
||||
<include reference="55u-lk-Vl8"/>
|
||||
<include reference="OdB-kn-E8t"/>
|
||||
<include reference="7Ce-Df-SWx"/>
|
||||
<include reference="PEI-qV-ay9"/>
|
||||
<include reference="cNA-Yf-qTv"/>
|
||||
<include reference="LFO-jd-axU"/>
|
||||
<include reference="wny-JX-bf3"/>
|
||||
<include reference="6Yc-1K-Ngl"/>
|
||||
<include reference="h2v-wj-aTe"/>
|
||||
<include reference="DtP-3P-vpf"/>
|
||||
<include reference="T1M-HW-h60"/>
|
||||
<include reference="ds9-gC-21F"/>
|
||||
<include reference="htl-Vj-x3w"/>
|
||||
<include reference="B28-e9-frX"/>
|
||||
<include reference="Egg-Ya-137"/>
|
||||
<include reference="eAd-Wu-obj"/>
|
||||
<include reference="k2e-YN-zp4"/>
|
||||
<include reference="qWu-f4-OGv"/>
|
||||
<include reference="sh3-oU-dEE"/>
|
||||
<include reference="1CI-nz-vpx"/>
|
||||
<exclude reference="6vG-Jg-fmU"/>
|
||||
<include reference="H9S-E2-xEW"/>
|
||||
<include reference="VWf-RY-YhF"/>
|
||||
<exclude reference="X7j-Pp-Rbz"/>
|
||||
<include reference="aeN-FP-LX6"/>
|
||||
<include reference="55u-lk-Vl8"/>
|
||||
<include reference="OdB-kn-E8t"/>
|
||||
<include reference="7J7-45-P5G"/>
|
||||
<include reference="hpD-Om-vt4"/>
|
||||
<include reference="qWu-f4-OGv"/>
|
||||
<include reference="sh3-oU-dEE"/>
|
||||
<include reference="DtP-3P-vpf"/>
|
||||
<include reference="T1M-HW-h60"/>
|
||||
<include reference="ds9-gC-21F"/>
|
||||
<include reference="htl-Vj-x3w"/>
|
||||
<include reference="LFO-jd-axU"/>
|
||||
<include reference="wny-JX-bf3"/>
|
||||
<include reference="PEI-qV-ay9"/>
|
||||
<include reference="cNA-Yf-qTv"/>
|
||||
<include reference="bud-iX-j0f"/>
|
||||
<include reference="ggx-3K-K1L"/>
|
||||
<include reference="9zK-3U-gYU"/>
|
||||
<include reference="60N-Dv-oSw"/>
|
||||
<include reference="K5d-es-d8h"/>
|
||||
<include reference="VDe-WO-sJU"/>
|
||||
<include reference="d08-t5-VT0"/>
|
||||
<include reference="7Ce-Df-SWx"/>
|
||||
<include reference="A7P-r9-8FC"/>
|
||||
<include reference="PaQ-6i-9mo"/>
|
||||
<include reference="B28-e9-frX"/>
|
||||
<include reference="Egg-Ya-137"/>
|
||||
<include reference="eAd-Wu-obj"/>
|
||||
<include reference="k2e-YN-zp4"/>
|
||||
<include reference="9zK-3U-gYU"/>
|
||||
<include reference="7J7-45-P5G"/>
|
||||
<include reference="hpD-Om-vt4"/>
|
||||
<include reference="1Qc-NM-cha"/>
|
||||
<include reference="7PG-72-xfy"/>
|
||||
<include reference="M9f-Bp-Gbg"/>
|
||||
|
|
|
|||
|
|
@ -10,31 +10,25 @@ import Foundation
|
|||
|
||||
class EmailRule: Rule {
|
||||
|
||||
let REGEX = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"
|
||||
var REGEX : String
|
||||
|
||||
init(){}
|
||||
init(){
|
||||
self.REGEX = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"
|
||||
}
|
||||
|
||||
init(regex:String){
|
||||
self.REGEX = regex
|
||||
REGEX = regex
|
||||
}
|
||||
|
||||
var message:String {
|
||||
return "Must be a valid email address"
|
||||
}
|
||||
|
||||
func validate(value:String) -> Bool {
|
||||
|
||||
if let emailTest = NSPredicate(format: "SELF MATCHES %@", REGEX) {
|
||||
if emailTest.evaluateWithObject(value) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
func validate(value: String) -> Bool {
|
||||
let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX)
|
||||
if test.evaluateWithObject(value) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func errorMessage() -> String {
|
||||
return self.message
|
||||
return "Must be a valid email address"
|
||||
}
|
||||
}
|
||||
|
|
@ -11,22 +11,24 @@ import Foundation
|
|||
|
||||
class MinLengthRule : Rule {
|
||||
|
||||
let DEFAULT_MIN_LENGTH:Int = 3
|
||||
private let DEFAULT_MIN_LENGTH: Int
|
||||
|
||||
init(){}
|
||||
init(){
|
||||
DEFAULT_MIN_LENGTH = 3
|
||||
}
|
||||
|
||||
init(length:Int){
|
||||
self.DEFAULT_MIN_LENGTH = length
|
||||
}
|
||||
|
||||
func errorMessage() -> String {
|
||||
return "Must be at least \(DEFAULT_MIN_LENGTH) characters long"
|
||||
}
|
||||
|
||||
func validate(value: String) -> Bool {
|
||||
if countElements(value) <= DEFAULT_MIN_LENGTH {
|
||||
if count(value) <= DEFAULT_MIN_LENGTH {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func errorMessage() -> String {
|
||||
return "Must be at least \(DEFAULT_MIN_LENGTH) characters long"
|
||||
}
|
||||
}
|
||||
|
|
@ -20,29 +20,25 @@ class PasswordRule : Rule {
|
|||
|
||||
// 8 characters. one uppercase
|
||||
|
||||
var REGEX = "^(?=.*?[A-Z]).{8,}$"
|
||||
private let REGEX: String
|
||||
|
||||
init(){}
|
||||
init(){
|
||||
self.REGEX = "^(?=.*?[A-Z]).{8,}$"
|
||||
}
|
||||
|
||||
init(regex:String){
|
||||
self.REGEX = regex
|
||||
}
|
||||
|
||||
var message:String {
|
||||
return "Must be 8 characters with 1 uppercase"
|
||||
}
|
||||
|
||||
func validate(value: String) -> Bool {
|
||||
if let passwordTes = NSPredicate(format: "SELF MATCHES %@", REGEX) {
|
||||
if passwordTes.evaluateWithObject(value) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX)
|
||||
if test.evaluateWithObject(value) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func errorMessage() -> String {
|
||||
return self.message
|
||||
return "Must be 8 characters with 1 uppercase"
|
||||
}
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "hideKeyboard"))
|
||||
|
||||
validator.registerField(fullNameTextField, errorLabel: fullNameErrorLabel , rules: [RequiredRule(), FullNameRule()])
|
||||
validator.registerField(emailTextField, errorLabel: emailErrorLabel, rules: [RequiredRule(), EmailRule()])
|
||||
|
|
@ -96,6 +97,10 @@ class ViewController: UIViewController , ValidationDelegate, UITextFieldDelegate
|
|||
error.errorLabel?.hidden = true
|
||||
}
|
||||
}
|
||||
|
||||
func hideKeyboard(){
|
||||
self.view.endEditing(true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,30 +9,25 @@
|
|||
import Foundation
|
||||
|
||||
class ZipCodeRule: Rule {
|
||||
let REGEX = "\\d{5}"
|
||||
private let REGEX: String
|
||||
|
||||
|
||||
init(){}
|
||||
init(){
|
||||
self.REGEX = "\\d{5}"
|
||||
}
|
||||
init(regex:String){
|
||||
self.REGEX = regex
|
||||
}
|
||||
|
||||
var message: String {
|
||||
return "Enter a valid 5 digit zipcode"
|
||||
}
|
||||
|
||||
func validate(value: String) -> Bool {
|
||||
if let zipTest = NSPredicate(format: "SELF MATCHES %@", REGEX) {
|
||||
if zipTest.evaluateWithObject(value) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
let test = NSPredicate(format: "SELF MATCHES %@", self.REGEX)
|
||||
if test.evaluateWithObject(value) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func errorMessage() -> String {
|
||||
return message
|
||||
return "Enter a valid 5 digit zipcode"
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue