Merge branch 'OptionalFunctionParameters' into ValidatableProtocol

# Conflicts:
#	SwiftValidator/Core/ValidationError.swift
#	SwiftValidator/Core/Validator.swift
This commit is contained in:
Deniz Adalar 2016-05-25 12:32:33 +03:00
commit f344bdc370
4 changed files with 9 additions and 29 deletions

View File

@ -21,7 +21,10 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.1"
use_frameworks!
pod 'SwiftValidator', '3.0.3'
# For SwiftValidator tag 3.0.3
pod 'SwiftValidator', '3.0.3'
# Recommended: For the most recent version of SwiftValidator (master branch)
pod 'SwiftValidator', :git => 'https://github.com/jpotts18/SwiftValidator.git', :branch => 'master'
```
Install into your project:
@ -161,3 +164,4 @@ Swift Validator is written and maintained by Jeff Potter [@jpotts18](http://twit
3. Commit your changes `git commit -am 'Add some feature'`
4. Push to the branch `git push origin my-new-feature`
5. Create a new Pull Request
6. Make sure code coverage is at least 70%

View File

@ -17,21 +17,9 @@ public class ValidationError: NSObject {
/// the error message of the field
public let errorMessage:String
/**
Initializes `ValidationError` object with a field and error.
- parameter field: Validatable field that holds field.
- parameter errorMessage: String that holds error message.
- returns: An initialized object, or nil if an object could not be created for some reason that would not result in an exception.
*/
public init(field:ValidatableField, error:String){
self.field = field
self.errorMessage = error
}
/**
Initializes `ValidationError` object with a field, errorLabel, and errorMessage.
- parameter field: Validatable field that holds field.
- parameter errorLabel: UILabel that holds error label.
- parameter errorMessage: String that holds error message.

View File

@ -97,19 +97,7 @@ public class Validator {
self.successStyleTransform = success
self.errorStyleTransform = error
}
/**
This method is used to add a field to validator.
- parameter field: field that is to be validated.
- parameter Rule: An array which holds different rules to validate against field.
- returns: No return value
*/
public func registerField(field:ValidatableField, rules:[Rule]) {
validations[field] = ValidationRule(field: field, rules: rules, errorLabel: nil)
fields[field] = field
}
/**
This method is used to add a field to validator.
@ -118,7 +106,7 @@ public class Validator {
- parameter rules: A Rule array that holds different rules that apply to said field.
- returns: No return value
*/
public func registerField(field: ValidatableField, errorLabel:UILabel, rules:[Rule]) {
public func registerField(field: ValidatableField, errorLabel:UILabel? = nil, rules:[Rule]) {
validations[field] = ValidationRule(field: field, rules:rules, errorLabel:errorLabel)
fields[field] = field
}

View File

@ -13,7 +13,7 @@ import Foundation
public class EmailRule: RegexRule {
/// Regular express string to be used in validation.
static let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"
static let regex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
/**
Initializes an `EmailRule` object to validate an email field.