Skip to content

Commit

Permalink
Merge pull request #3 from dtop/feature/rc5
Browse files Browse the repository at this point in the history
feature/rc5
  • Loading branch information
Danilo Topalovic committed Dec 27, 2015
2 parents 27e5297 + e619a0f commit fda1954
Show file tree
Hide file tree
Showing 44 changed files with 1,118 additions and 254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ DerivedData
# Carthage/Checkouts

Carthage/Build
*.DS_*
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: objective-c
osx_image: xcode7
env:
- DESTINATION="OS=9.0,name=iPhone 6" SCHEME="validate" SDK=iphonesimulator9.0
- DESTINATION="OS=9.0,name=iPhone 6" SCHEME="SwiftValidate" SDK=iphonesimulator9.0
before_install:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
script:
- set -o pipefail
- xcodebuild -version
- xcodebuild -project validate.xcodeproj -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION"
- xcodebuild -project SwiftValidate.xcodeproj -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION"
-configuration Debug ONLY_ACTIVE_ARCH=NO test | xcpretty -c
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# swift-validate
# SwiftValidate
[![Build Status](https://travis-ci.org/dtop/SwiftValidate.svg)](https://travis-ci.org/dtop/SwiftValidate)
[![Compatibility](https://img.shields.io/badge/Swift-2.1-blue.svg)](https://developer.apple.com/swift)
[![DependencyManagement](https://img.shields.io/badge/CocoaPods-Compatible-brightgreen.svg)](https://cocoapods.org)
Expand Down Expand Up @@ -87,7 +87,7 @@ let errors = validatorChain.errors

If you are dealing with a lot of values (e.g. a form result) you can easily predefine an ValidationIterator and add several chains linked to the form fields name to it.

see the extraction of the ValidatorChainTests:
see the extraction of the ValidationIteratorTests:

```swift

Expand Down Expand Up @@ -276,7 +276,7 @@ Validates if the given value is a valid number
| value | type | default | description |
|----------------------|:-----------------:|---------|------------------------------------|
| `allowNil` | Bool | true | nil is allowed |
| `canBeString` | Bool | true | value can be a numerical string |
| `allowString` | Bool | true | value can be a numerical string |
| `allowFloatingPoint` | Bool | true | value can be a floatingpoint value |

**Error Messages**
Expand All @@ -289,12 +289,14 @@ Validates if the given value is a valid number
Validates if a numerical value is between 2 predefined values

Generic:

```swift
let validator = ValidatorBetween<Double>() {
$0.minValue = 1.0
$0.maxValue = 99.1
}
```

**Configuration**

| value | type | default | description |
Expand All @@ -317,6 +319,7 @@ let validator = ValidatorBetween<Double>() {
Validates if the given value is greater than the predefined one

Generic:

```swift
let validator = ValidatorGreaterThan<Double>() {
$0.min = 1.0
Expand All @@ -342,6 +345,7 @@ let validator = ValidatorGreaterThan<Double>() {
Validates if the given value is smaller than the predefined one

Generic:

```swift
let validator = ValidatorSmallerThan<Double>() {
$0.max = 10.0
Expand Down
6 changes: 3 additions & 3 deletions SwiftValidate.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Pod::Spec.new do |s|

s.name = "SwiftValidate"
s.version = "0.0.4"
s.version = "0.0.5"
s.summary = "A highly customizable validation library for swift"
s.homepage = "http://github.com/dtop/swift-validate"
s.homepage = "http://github.com/dtop/SwiftValidate"
s.license = "MIT"
s.author = { "Danilo Topalovic" => "danilo.topalovic@nerdsee.com" }
s.ios.deployment_target = "8.0"
s.ios.frameworks = 'UIKit', 'Foundation'
s.source = { :git => "https://github.com/dtop/swift-validate.git", :tag => s.version }
s.source = { :git => "https://github.com/dtop/SwiftValidate.git", :tag => s.version }
s.source_files = "validate/*.swift", "validate/**/*.swift"
end
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
9F88DF781C2D5C8600E8CA4B /* ValidatorRequired.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F88DF771C2D5C8600E8CA4B /* ValidatorRequired.swift */; };
9F88DF7A1C2D620C00E8CA4B /* ValidatorRequiredTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F88DF791C2D620C00E8CA4B /* ValidatorRequiredTests.swift */; };
9FCB7D801C26021900887033 /* validate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FCB7D7F1C26021900887033 /* validate.h */; settings = {ATTRIBUTES = (Public, ); }; };
9FCB7D871C26021900887033 /* validate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FCB7D7C1C26021900887033 /* validate.framework */; };
9FCB7D871C26021900887033 /* SwiftValidate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FCB7D7C1C26021900887033 /* SwiftValidate.framework */; };
9FCB7D8C1C26021900887033 /* ValidatorChainTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCB7D8B1C26021900887033 /* ValidatorChainTests.swift */; };
9FCB7D9A1C26024100887033 /* BaseValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCB7D961C26024100887033 /* BaseValidator.swift */; };
9FCB7D9B1C26024100887033 /* ValidationAwareProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCB7D971C26024100887033 /* ValidationAwareProtocol.swift */; };
Expand Down Expand Up @@ -78,10 +78,10 @@
9F11AE981C2DA30B00D2FB29 /* ValidationIteratorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidationIteratorTests.swift; sourceTree = "<group>"; };
9F88DF771C2D5C8600E8CA4B /* ValidatorRequired.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ValidatorRequired.swift; path = Validators/ValidatorRequired.swift; sourceTree = "<group>"; };
9F88DF791C2D620C00E8CA4B /* ValidatorRequiredTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidatorRequiredTests.swift; sourceTree = "<group>"; };
9FCB7D7C1C26021900887033 /* validate.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = validate.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9FCB7D7C1C26021900887033 /* SwiftValidate.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftValidate.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9FCB7D7F1C26021900887033 /* validate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = validate.h; sourceTree = "<group>"; };
9FCB7D811C26021900887033 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9FCB7D861C26021900887033 /* validateTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = validateTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
9FCB7D861C26021900887033 /* SwiftValidate.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftValidate.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
9FCB7D8B1C26021900887033 /* ValidatorChainTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidatorChainTests.swift; sourceTree = "<group>"; };
9FCB7D8D1C26021900887033 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9FCB7D961C26024100887033 /* BaseValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseValidator.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -115,7 +115,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9FCB7D871C26021900887033 /* validate.framework in Frameworks */,
9FCB7D871C26021900887033 /* SwiftValidate.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -167,8 +167,8 @@
9FCB7D7D1C26021900887033 /* Products */ = {
isa = PBXGroup;
children = (
9FCB7D7C1C26021900887033 /* validate.framework */,
9FCB7D861C26021900887033 /* validateTests.xctest */,
9FCB7D7C1C26021900887033 /* SwiftValidate.framework */,
9FCB7D861C26021900887033 /* SwiftValidate.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -280,9 +280,9 @@
/* End PBXHeadersBuildPhase section */

/* Begin PBXNativeTarget section */
9FCB7D7B1C26021900887033 /* validate */ = {
9FCB7D7B1C26021900887033 /* SwiftValidate */ = {
isa = PBXNativeTarget;
buildConfigurationList = 9FCB7D901C26021900887033 /* Build configuration list for PBXNativeTarget "validate" */;
buildConfigurationList = 9FCB7D901C26021900887033 /* Build configuration list for PBXNativeTarget "SwiftValidate" */;
buildPhases = (
9FCB7D771C26021900887033 /* Sources */,
9FCB7D781C26021900887033 /* Frameworks */,
Expand All @@ -294,14 +294,14 @@
);
dependencies = (
);
name = validate;
name = SwiftValidate;
productName = validate;
productReference = 9FCB7D7C1C26021900887033 /* validate.framework */;
productReference = 9FCB7D7C1C26021900887033 /* SwiftValidate.framework */;
productType = "com.apple.product-type.framework";
};
9FCB7D851C26021900887033 /* validateTests */ = {
9FCB7D851C26021900887033 /* SwiftValidateTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 9FCB7D931C26021900887033 /* Build configuration list for PBXNativeTarget "validateTests" */;
buildConfigurationList = 9FCB7D931C26021900887033 /* Build configuration list for PBXNativeTarget "SwiftValidateTests" */;
buildPhases = (
9FCB7D821C26021900887033 /* Sources */,
9FCB7D831C26021900887033 /* Frameworks */,
Expand All @@ -312,9 +312,9 @@
dependencies = (
9FCB7D891C26021900887033 /* PBXTargetDependency */,
);
name = validateTests;
name = SwiftValidateTests;
productName = validateTests;
productReference = 9FCB7D861C26021900887033 /* validateTests.xctest */;
productReference = 9FCB7D861C26021900887033 /* SwiftValidate.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
Expand All @@ -335,7 +335,7 @@
};
};
};
buildConfigurationList = 9FCB7D761C26021900887033 /* Build configuration list for PBXProject "validate" */;
buildConfigurationList = 9FCB7D761C26021900887033 /* Build configuration list for PBXProject "SwiftValidate" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
Expand All @@ -347,8 +347,8 @@
projectDirPath = "";
projectRoot = "";
targets = (
9FCB7D7B1C26021900887033 /* validate */,
9FCB7D851C26021900887033 /* validateTests */,
9FCB7D7B1C26021900887033 /* SwiftValidate */,
9FCB7D851C26021900887033 /* SwiftValidateTests */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -443,7 +443,7 @@
/* Begin PBXTargetDependency section */
9FCB7D891C26021900887033 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 9FCB7D7B1C26021900887033 /* validate */;
target = 9FCB7D7B1C26021900887033 /* SwiftValidate */;
targetProxy = 9FCB7D881C26021900887033 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
Expand Down Expand Up @@ -550,7 +550,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.danilo-topalovic.validate";
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_NAME = SwiftValidate;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
Expand All @@ -568,7 +568,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.danilo-topalovic.validate";
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_NAME = SwiftValidate;
SKIP_INSTALL = YES;
};
name = Release;
Expand All @@ -579,7 +579,8 @@
INFOPLIST_FILE = validateTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.danilo-topalovic.validateTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)Tests";
PRODUCT_NAME = SwiftValidate;
};
name = Debug;
};
Expand All @@ -589,14 +590,15 @@
INFOPLIST_FILE = validateTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.danilo-topalovic.validateTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)Tests";
PRODUCT_NAME = SwiftValidate;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
9FCB7D761C26021900887033 /* Build configuration list for PBXProject "validate" */ = {
9FCB7D761C26021900887033 /* Build configuration list for PBXProject "SwiftValidate" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9FCB7D8E1C26021900887033 /* Debug */,
Expand All @@ -605,7 +607,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9FCB7D901C26021900887033 /* Build configuration list for PBXNativeTarget "validate" */ = {
9FCB7D901C26021900887033 /* Build configuration list for PBXNativeTarget "SwiftValidate" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9FCB7D911C26021900887033 /* Debug */,
Expand All @@ -614,7 +616,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9FCB7D931C26021900887033 /* Build configuration list for PBXNativeTarget "validateTests" */ = {
9FCB7D931C26021900887033 /* Build configuration list for PBXNativeTarget "SwiftValidateTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9FCB7D941C26021900887033 /* Debug */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FCB7D7B1C26021900887033"
BuildableName = "validate.framework"
BlueprintName = "validate"
ReferencedContainer = "container:validate.xcodeproj">
BuildableName = "SwiftValidate.framework"
BlueprintName = "SwiftValidate"
ReferencedContainer = "container:SwiftValidate.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -26,26 +26,27 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FCB7D851C26021900887033"
BuildableName = "validateTests.xctest"
BlueprintName = "validateTests"
ReferencedContainer = "container:validate.xcodeproj">
BuildableName = "SwiftValidate.xctest"
BlueprintName = "SwiftValidateTests"
ReferencedContainer = "container:SwiftValidate.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FCB7D7B1C26021900887033"
BuildableName = "validate.framework"
BlueprintName = "validate"
ReferencedContainer = "container:validate.xcodeproj">
BuildableName = "SwiftValidate.framework"
BlueprintName = "SwiftValidate"
ReferencedContainer = "container:SwiftValidate.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
Expand All @@ -65,9 +66,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FCB7D7B1C26021900887033"
BuildableName = "validate.framework"
BlueprintName = "validate"
ReferencedContainer = "container:validate.xcodeproj">
BuildableName = "SwiftValidate.framework"
BlueprintName = "SwiftValidate"
ReferencedContainer = "container:SwiftValidate.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
Expand All @@ -83,9 +84,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9FCB7D7B1C26021900887033"
BuildableName = "validate.framework"
BlueprintName = "validate"
ReferencedContainer = "container:validate.xcodeproj">
BuildableName = "SwiftValidate.framework"
BlueprintName = "SwiftValidate"
ReferencedContainer = "container:SwiftValidate.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
Expand Down

This file was deleted.

8 changes: 8 additions & 0 deletions validate/BaseValidator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@ public class BaseValidator: ValidationAwareProtocol {

return false
}

/**
Empties the errors for the next run
*/
func emptyErrors() {

self.errors = [String]()
}
}
2 changes: 1 addition & 1 deletion validate/Helpers/NumberConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

class NumberConverter<TYPE: SignedNumberType> {
internal class NumberConverter<TYPE: SignedNumberType> {

/**
Tries a conversion to double
Expand Down
Loading

0 comments on commit fda1954

Please sign in to comment.