Skip to content

Commit

Permalink
Merge pull request #13 from dtop/feature/RC1.0
Browse files Browse the repository at this point in the history
feature/rc1.0
  • Loading branch information
Danilo Topalovic committed Mar 18, 2016
2 parents c5b1bc0 + 7135acb commit 00c9224
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Version History

### Version 1.0.0

- cleaned the code a little

### Version 0.0.9

- fixed bugs within the generic iterators (thanks @jpaas)
Expand Down
2 changes: 1 addition & 1 deletion SwiftValidate.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SwiftValidate"
s.version = "0.0.9"
s.version = "1.0.0"
s.summary = "A highly customizable validation library for swift"
s.homepage = "http://github.com/dtop/SwiftValidate"
s.license = "MIT"
Expand Down
7 changes: 3 additions & 4 deletions validate/Validators/ValidatorBetween.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public class ValidatorBetween<TYPE: SignedNumberType>: ValidatorProtocol, Valida

// MARK: comparision closures

private let compareExclusive = { (alpha: TYPE, bravo: TYPE ) -> Bool in return alpha > bravo }
private let compareInclusive = { (alpha: TYPE, bravo: TYPE ) -> Bool in return alpha >= bravo }
private let comparator = { (alpha: TYPE, bravo: TYPE, comp: (TYPE, TYPE) -> Bool) -> Bool in return comp(alpha, bravo) }

// MARK: methods

Expand Down Expand Up @@ -90,8 +89,8 @@ public class ValidatorBetween<TYPE: SignedNumberType>: ValidatorProtocol, Valida

if let myNum: TYPE = value as? TYPE {

let leftOk = (self.minInclusive) ? self.compareInclusive(myNum, self.minValue) : self.compareExclusive(myNum, self.minValue)
let rightOk = (self.maxInclusive) ? self.compareInclusive(self.maxValue, myNum) : self.compareExclusive(self.maxValue, myNum)
let leftOk = (self.minInclusive) ? self.comparator(myNum, self.minValue, >=) : self.comparator(myNum, self.minValue, >)
let rightOk = (self.maxInclusive) ? self.comparator(myNum, self.maxValue, <=) : self.comparator(myNum, self.maxValue, <)

if leftOk && rightOk {
return true
Expand Down
6 changes: 3 additions & 3 deletions validate/Validators/ValidatorGreaterThan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class ValidatorGreaterThan<TYPE: SignedNumberType>: ValidatorProtocol, Va

//MARK: comparision functions

private let compareExclusive = { (alpha: TYPE, bravo: TYPE ) -> Bool in return alpha > bravo }
private let compareInclusive = { (alpha: TYPE, bravo: TYPE ) -> Bool in return alpha >= bravo }
private let comparator = { (alpha: TYPE, bravo: TYPE, comp: (TYPE, TYPE) -> Bool) -> Bool in return comp(alpha, bravo) }

//MARK: methods

Expand Down Expand Up @@ -116,7 +115,8 @@ public class ValidatorGreaterThan<TYPE: SignedNumberType>: ValidatorProtocol, Va
*/
private func compareAsNumber(value: TYPE) -> Bool {

let result = (self.inclusive) ? self.compareInclusive(value, self.min) : self.compareExclusive(value, self.min)
let result = (self.inclusive) ? self.comparator(value, self.min, >=) : self.comparator(value, self.min, >)

if !result {

self._err.append(String(format: self.errorMessageNotGreaterThan, String(self.min)))
Expand Down
6 changes: 3 additions & 3 deletions validate/Validators/ValidatorSmallerThan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class ValidatorSmallerThan<TYPE: SignedNumberType>: ValidatorProtocol, Va

//MARK: comparision functions

private let compareExclusive = { (alpha: TYPE, bravo: TYPE ) -> Bool in return alpha > bravo }
private let compareInclusive = { (alpha: TYPE, bravo: TYPE ) -> Bool in return alpha >= bravo }
private let comparator = { (alpha: TYPE, bravo: TYPE, comp: (TYPE, TYPE) -> Bool) -> Bool in return comp(alpha, bravo) }

//MARK: methods

Expand Down Expand Up @@ -116,7 +115,8 @@ public class ValidatorSmallerThan<TYPE: SignedNumberType>: ValidatorProtocol, Va
*/
private func compareAsNumber(value: TYPE) -> Bool {

let result = (self.inclusive) ? self.compareInclusive(self.max, value) : self.compareExclusive(self.max, value)
let result = (self.inclusive) ? self.comparator(value, self.max, <=) : self.comparator(value, self.max, <)

if !result {

self._err.append(String(format: self.errorMessageNotSmallerThan, String(self.max)))
Expand Down

0 comments on commit 00c9224

Please sign in to comment.