Move example project to CocoaPods

This commit is contained in:
Roman Efimov
2013-09-06 10:26:06 -05:00
parent 3b3269bd54
commit e5ae478d2e
57 changed files with 2243 additions and 82 deletions

View File

@@ -24,8 +24,8 @@
//
#import <Foundation/Foundation.h>
#import <REValidation/REValidation.h>
#import "RETableViewCellStyle.h"
#import "REValidation.h"
@class RETableViewSection;

View File

@@ -24,6 +24,7 @@
//
#import <UIKit/UIKit.h>
#import <REValidation/REValidation.h>
#import "RETableViewSection.h"
#import "RETableViewCellStyle.h"
#import "RETableViewCell.h"
@@ -44,7 +45,6 @@
#import "REFloatItem.h"
#import "REDateTimeItem.h"
#import "REMultipleChoiceItem.h"
#import "REValidation.h"
@protocol RETableViewManagerDelegate;

View File

@@ -0,0 +1,3 @@
platform :ios, '6.0'
pod 'REFormattedNumberField'
pod 'REValidation'

View File

@@ -0,0 +1,13 @@
PODS:
- REFormattedNumberField (1.0.4)
- REValidation (0.1.3)
DEPENDENCIES:
- REFormattedNumberField
- REValidation
SPEC CHECKSUMS:
REFormattedNumberField: 74ac0f5ce7001102a461dd025d34c93be7794a00
REValidation: 2368d2f4d3b44777a938ab2650a6e0c5c3d1fbba
COCOAPODS: 0.24.0

View File

@@ -0,0 +1 @@
../../REFormattedNumberField/REFormattedNumberField/REFormattedNumberField.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/NSError+REValidation.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/REEmailValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/RELengthValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/REPresenceValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/REURLValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/REValidation.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/REValidator.h

View File

@@ -0,0 +1 @@
../../REFormattedNumberField/REFormattedNumberField/REFormattedNumberField.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/NSError+REValidation.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/REEmailValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/RELengthValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/REPresenceValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/Validators/REURLValidator.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/REValidation.h

View File

@@ -0,0 +1 @@
../../REValidation/REValidation/REValidator.h

View File

@@ -0,0 +1,13 @@
PODS:
- REFormattedNumberField (1.0.4)
- REValidation (0.1.3)
DEPENDENCIES:
- REFormattedNumberField
- REValidation
SPEC CHECKSUMS:
REFormattedNumberField: 74ac0f5ce7001102a461dd025d34c93be7794a00
REValidation: 2368d2f4d3b44777a938ab2650a6e0c5c3d1fbba
COCOAPODS: 0.24.0

View File

@@ -0,0 +1,5 @@
#include "Pods-REFormattedNumberField.xcconfig"
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/REFormattedNumberField" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/REFormattedNumberField" "${PODS_ROOT}/Headers/REValidation"
OTHER_LDFLAGS = -ObjC
PODS_ROOT = ${SRCROOT}

View File

@@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_Pods_REFormattedNumberField : NSObject
@end
@implementation PodsDummy_Pods_REFormattedNumberField
@end

View File

@@ -0,0 +1,5 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "Pods-environment.h"

View File

@@ -0,0 +1,5 @@
#include "Pods-REValidation.xcconfig"
GCC_PREPROCESSOR_DEFINITIONS = COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders" "${PODS_ROOT}/BuildHeaders/REValidation" "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/REFormattedNumberField" "${PODS_ROOT}/Headers/REValidation"
OTHER_LDFLAGS = -ObjC
PODS_ROOT = ${SRCROOT}

View File

@@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_Pods_REValidation : NSObject
@end
@implementation PodsDummy_Pods_REValidation
@end

View File

@@ -0,0 +1,5 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "Pods-environment.h"

View File

@@ -0,0 +1,47 @@
# Acknowledgements
This application makes use of the following third party libraries:
## REFormattedNumberField
Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## REValidation
Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Generated by CocoaPods - http://cocoapods.org

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string>This application makes use of the following third party libraries:</string>
<key>Title</key>
<string>Acknowledgements</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</string>
<key>Title</key>
<string>REFormattedNumberField</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</string>
<key>Title</key>
<string>REValidation</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Generated by CocoaPods - http://cocoapods.org</string>
<key>Title</key>
<string></string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
</array>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>Title</key>
<string>Acknowledgements</string>
</dict>
</plist>

View File

@@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_Pods : NSObject
@end
@implementation PodsDummy_Pods
@end

View File

@@ -0,0 +1,20 @@
// To check if a library is compiled with CocoaPods you
// can use the `COCOAPODS` macro definition which is
// defined in the xcconfigs so it is available in
// headers also when they are imported in the client
// project.
// REFormattedNumberField
#define COCOAPODS_POD_AVAILABLE_REFormattedNumberField
#define COCOAPODS_VERSION_MAJOR_REFormattedNumberField 1
#define COCOAPODS_VERSION_MINOR_REFormattedNumberField 0
#define COCOAPODS_VERSION_PATCH_REFormattedNumberField 4
// REValidation
#define COCOAPODS_POD_AVAILABLE_REValidation
#define COCOAPODS_VERSION_MAJOR_REValidation 0
#define COCOAPODS_VERSION_MINOR_REValidation 1
#define COCOAPODS_VERSION_PATCH_REValidation 3

View File

@@ -0,0 +1,44 @@
#!/bin/sh
set -e
RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
> "$RESOURCES_TO_COPY"
install_resource()
{
case $1 in
*.storyboard)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
;;
*.xib)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
;;
*.framework)
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
;;
*.xcdatamodel)
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
;;
*.xcdatamodeld)
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
;;
/*)
echo "$1"
echo "$1" >> "$RESOURCES_TO_COPY"
;;
*)
echo "${PODS_ROOT}/$1"
echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
;;
esac
}
rsync -avr --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
rm -f "$RESOURCES_TO_COPY"

View File

@@ -0,0 +1,4 @@
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/REFormattedNumberField" "${PODS_ROOT}/Headers/REValidation"
OTHER_LDFLAGS = -ObjC
PODS_ROOT = ${SRCROOT}/Pods

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,104 @@
# REFormattedNumberField
UITextField subclass that allows numeric input in a predefined format.
![Screenshot of REFormattedNumberField](https://github.com/romaonthego/REFormattedNumberField/raw/master/Screenshot.png "REFormattedNumberField Screenshot")
## Requirements
* Xcode 4.5 or higher
* Apple LLVM compiler
* iOS 5.0 or higher
* ARC
## Demo
Build and run the `REFormattedNumberFieldExample` project in Xcode to see `REFormattedNumberField` in action.
## Installation
### CocoaPods
The recommended approach for installating `REFormattedNumberField` is via the [CocoaPods](http://cocoapods.org/) package manager, as it provides flexible dependency management and dead simple installation.
For best results, it is recommended that you install via CocoaPods >= **0.15.2** using Git >= **1.8.0** installed via Homebrew.
Install CocoaPods if not already available:
``` bash
$ [sudo] gem install cocoapods
$ pod setup
```
Change to the directory of your Xcode project:
``` bash
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
```
Edit your Podfile and add REFormattedNumberField:
``` bash
platform :ios, '5.0'
pod 'REFormattedNumberField', '~> 1.0.4'
```
Install into your Xcode project:
``` bash
$ pod install
```
Open your project in Xcode from the .xcworkspace file (not the usual project file)
``` bash
$ open MyProject.xcworkspace
```
Please note that if your installation fails, it may be because you are installing with a version of Git lower than CocoaPods is expecting. Please ensure that you are running Git >= **1.8.0** by executing `git --version`. You can get a full picture of the installation details by executing `pod install --verbose`.
### Manual Install
All you need to do is drop `REFormattedNumberField` files into your project, and add `#include "REFormattedNumberField.h"` to the top of classes that will use it.
## Example Usage
Pretty much all you need is just to specify `format` NSString, where `X` are digits and all other characters are separators.
``` objective-c
REFormattedNumberField *phoneField1 = [[REFormattedNumberField alloc] initWithFrame:CGRectMake(20, 20, 280, 30)];
phoneField1.format = @"(XXX) XXX-XXXX";
[self.view addSubview:phoneField1];
REFormattedNumberField *phoneField2 = [[REFormattedNumberField alloc] initWithFrame:CGRectMake(20, 80, 280, 30)];
phoneField2.format = @"+X (XXX) XXX-XXXX";
[self.view addSubview:phoneField2];
REFormattedNumberField *ccField = [[REFormattedNumberField alloc] initWithFrame:CGRectMake(20, 140, 280, 30)];
ccField.format = @"XXXX XXXX XXXX XXXX";
[self.view addSubview:ccField];
REFormattedNumberField *ccExpirationField = [[REFormattedNumberField alloc] initWithFrame:CGRectMake(20, 200, 280, 30)];
ccExpirationField.format = @"XX/XX";
[self.view addSubview:ccExpirationField];
```
## Contact
Roman Efimov
- https://github.com/romaonthego
- https://twitter.com/romaonthego
- romefimov@gmail.com
## License
REFormattedNumberField is available under the MIT license.
Copyright © 2013 Roman Efimov.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,19 @@
Copyright (c) 2013 Roman Efimov (https://github.com/romaonthego).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,166 @@
# REValidation
Simple Objective-C object validation.
Currently available default validators:
> * Presence validator
* String length validator
* Email validator
## Requirements
* Xcode 4.5 or higher
* Apple LLVM compiler
* iOS 5.0 or higher / Mac OS X 10.7 or higher
* ARC
## Installation
### CocoaPods
The recommended approach for installating `REValidation` is via the [CocoaPods](http://cocoapods.org/) package manager, as it provides flexible dependency management and dead simple installation.
For best results, it is recommended that you install via CocoaPods >= **0.15.2** using Git >= **1.8.0** installed via Homebrew.
Install CocoaPods if not already available:
``` bash
$ [sudo] gem install cocoapods
$ pod setup
```
Change to the directory of your Xcode project:
``` bash
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
```
Edit your Podfile and add REValidation:
``` bash
pod 'REValidation', '~> 0.1.1'
```
Install into your Xcode project:
``` bash
$ pod install
```
Open your project in Xcode from the .xcworkspace file (not the usual project file)
``` bash
$ open MyProject.xcworkspace
```
Please note that if your installation fails, it may be because you are installing with a version of Git lower than CocoaPods is expecting. Please ensure that you are running Git >= **1.8.0** by executing `git --version`. You can get a full picture of the installation details by executing `pod install --verbose`.
### Manual Install
All you need to do is drop `REValidation` files into your project, and add `#include "REValidation.h"` to the top of classes that will use it.
## Example Usage
``` objective-c
[REValidation registerDefaultValidators];
[REValidation registerDefaultErrorMessages];
NSString *emailString = @"test#@example.com";
NSArray *errors = [REValidation validateObject:emailString name:@"Email" validators:@[ @"presence", @"length(3, 20)", @"email" ]];
for (NSError *error in errors)
NSLog(@"Error: %@", error.localizedDescription);
// Alternatively you can use REValidator instances
//
NSString *testString = @"";
errors = [REValidation validateObject:testString name:@"Test string" validators:@[ [REPresenceValidator validator], [RELengthValidator validatorWithParameters:@{ @"min": @3, @"max": @10}] ]];
for (NSError *error in errors)
NSLog(@"Error: %@", error.localizedDescription);
```
It's easy to implement a custom validator, you need to subclass from `REValidator` and implement three methods:
```objective-c
+ (NSString *)name;
+ (NSDictionary *)parseParameterString:(NSString *)string;
+ (NSError *)validateObject:(NSString *)object variableName:(NSString *)name parameters:(NSDictionary *)parameters;
```
For example:
```objective-c
+ (NSString *)name
{
return @"length";
}
+ (NSDictionary *)parseParameterString:(NSString *)string
{
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\\d+)" options:0 error:&error];
NSArray *matches = [regex matchesInString:string options:0 range:NSMakeRange(0, string.length)];
NSMutableArray *results = [NSMutableArray array];
for (NSTextCheckingResult *matchResult in matches) {
NSString *match = [string substringWithRange:[matchResult range]];
[results addObject:match];
}
if (results.count == 2) {
return @{ @"min": results[0], @"max": results[1]};
}
return nil;
}
+ (NSError *)validateObject:(NSString *)object variableName:(NSString *)name parameters:(NSDictionary *)parameters
{
NSUInteger minimumValue = [parameters[@"min"] integerValue];
NSUInteger maximumValue = [parameters[@"max"] integerValue];
if (object.length < minimumValue && minimumValue > 0)
return [NSError re_validationErrorForDomain:@"com.REValidation.minimumLength", name, minimumValue];
if (object.length > maximumValue && maximumValue > 0)
return [NSError re_validationErrorForDomain:@"com.REValidation.maximumLength", name, maximumValue];
return nil;
}
```
It's possible to add validations without subclassing `REValidator` class using inline validations. Here's an example that shows how to use inline validations with [RETableViewManager](https://github.com/romaonthego/RETableViewManager):
```objective-c
REValidator *nameValidator = [REValidator validator];
nameValidator.inlineValidation = ^NSError *(NSString *string, NSString *name) {
if ([string componentsSeparatedByString:@" "].count < 2) {
return [NSError errorWithDomain:@"" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Please enter first and last name."}];
}
return nil;
};
RETextItem *nameItem = [RETextItem itemWithTitle:@"" value:self.contact.name placeholder:@"First & Last Name"];
nameItem.autocapitalizationType = UITextAutocapitalizationTypeWords;
nameItem.validators = @[nameValidator];
```
## Contact
Roman Efimov
- https://github.com/romaonthego
- https://twitter.com/romaonthego
- romefimov@gmail.com
## License
REValidation is available under the MIT license.
Copyright © 2013 Roman Efimov.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -38,15 +38,7 @@
30939CF217949A10004D95A9 /* userpic4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 30939CE617949A10004D95A9 /* userpic4.jpg */; };
30939CF317949A10004D95A9 /* userpic5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 30939CE717949A10004D95A9 /* userpic5.jpg */; };
30939CF417949A10004D95A9 /* userpic6.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 30939CE817949A10004D95A9 /* userpic6.jpg */; };
30939CF917949B2D004D95A9 /* REFormattedNumberField.m in Sources */ = {isa = PBXBuildFile; fileRef = 30939CF817949B2D004D95A9 /* REFormattedNumberField.m */; };
30B00D5E17C56EEF0010D439 /* NSError+REValidation.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00D5217C56EEF0010D439 /* NSError+REValidation.m */; };
30B00D5F17C56EEF0010D439 /* REValidation.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00D5417C56EEF0010D439 /* REValidation.m */; };
30B00D6017C56EEF0010D439 /* REValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00D5617C56EEF0010D439 /* REValidator.m */; };
30B00D6117C56EEF0010D439 /* REEmailValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00D5917C56EEF0010D439 /* REEmailValidator.m */; };
30B00D6217C56EEF0010D439 /* RELengthValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00D5B17C56EEF0010D439 /* RELengthValidator.m */; };
30B00D6317C56EEF0010D439 /* REPresenceValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00D5D17C56EEF0010D439 /* REPresenceValidator.m */; };
30B00D7A17C667A90010D439 /* ValidationsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00D7917C667A90010D439 /* ValidationsViewController.m */; };
30B00DEE17D8E9CE0010D439 /* REURLValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B00DED17D8E90D0010D439 /* REURLValidator.m */; };
30D1C7D617AC08F4001F731C /* First_Alt@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30D1C7D217AC08F3001F731C /* First_Alt@2x.png */; };
30D1C7D717AC08F4001F731C /* Last_Alt@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30D1C7D317AC08F3001F731C /* Last_Alt@2x.png */; };
30D1C7D817AC08F4001F731C /* Middle_Alt@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30D1C7D417AC08F3001F731C /* Middle_Alt@2x.png */; };
@@ -91,6 +83,7 @@
30FE4161176A32C300F317B8 /* Middle@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30FE4158176A32C300F317B8 /* Middle@2x.png */; };
30FE4162176A32C300F317B8 /* Single_Selected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30FE4159176A32C300F317B8 /* Single_Selected@2x.png */; };
30FE4163176A32C300F317B8 /* Single@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 30FE415A176A32C300F317B8 /* Single@2x.png */; };
53378ADE88FA40FD87184931 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EA85FF11E7E458B98D5825C /* libPods.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -141,24 +134,8 @@
30939CE617949A10004D95A9 /* userpic4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = userpic4.jpg; sourceTree = "<group>"; };
30939CE717949A10004D95A9 /* userpic5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = userpic5.jpg; sourceTree = "<group>"; };
30939CE817949A10004D95A9 /* userpic6.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = userpic6.jpg; sourceTree = "<group>"; };
30939CF717949B2D004D95A9 /* REFormattedNumberField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REFormattedNumberField.h; sourceTree = "<group>"; };
30939CF817949B2D004D95A9 /* REFormattedNumberField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = REFormattedNumberField.m; sourceTree = "<group>"; };
30B00D5117C56EEF0010D439 /* NSError+REValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+REValidation.h"; sourceTree = "<group>"; };
30B00D5217C56EEF0010D439 /* NSError+REValidation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+REValidation.m"; sourceTree = "<group>"; };
30B00D5317C56EEF0010D439 /* REValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REValidation.h; sourceTree = "<group>"; };
30B00D5417C56EEF0010D439 /* REValidation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = REValidation.m; sourceTree = "<group>"; };
30B00D5517C56EEF0010D439 /* REValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REValidator.h; sourceTree = "<group>"; };
30B00D5617C56EEF0010D439 /* REValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = REValidator.m; sourceTree = "<group>"; };
30B00D5817C56EEF0010D439 /* REEmailValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REEmailValidator.h; sourceTree = "<group>"; };
30B00D5917C56EEF0010D439 /* REEmailValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = REEmailValidator.m; sourceTree = "<group>"; };
30B00D5A17C56EEF0010D439 /* RELengthValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RELengthValidator.h; sourceTree = "<group>"; };
30B00D5B17C56EEF0010D439 /* RELengthValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RELengthValidator.m; sourceTree = "<group>"; };
30B00D5C17C56EEF0010D439 /* REPresenceValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REPresenceValidator.h; sourceTree = "<group>"; };
30B00D5D17C56EEF0010D439 /* REPresenceValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = REPresenceValidator.m; sourceTree = "<group>"; };
30B00D7817C667A90010D439 /* ValidationsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValidationsViewController.h; sourceTree = "<group>"; };
30B00D7917C667A90010D439 /* ValidationsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ValidationsViewController.m; sourceTree = "<group>"; };
30B00DEC17D8E90D0010D439 /* REURLValidator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = REURLValidator.h; sourceTree = "<group>"; };
30B00DED17D8E90D0010D439 /* REURLValidator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = REURLValidator.m; sourceTree = "<group>"; };
30D1C7D217AC08F3001F731C /* First_Alt@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "First_Alt@2x.png"; path = "Resources/First_Alt@2x.png"; sourceTree = "<group>"; };
30D1C7D317AC08F3001F731C /* Last_Alt@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Last_Alt@2x.png"; path = "Resources/Last_Alt@2x.png"; sourceTree = "<group>"; };
30D1C7D417AC08F3001F731C /* Middle_Alt@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Middle_Alt@2x.png"; path = "Resources/Middle_Alt@2x.png"; sourceTree = "<group>"; };
@@ -229,6 +206,8 @@
30FE4158176A32C300F317B8 /* Middle@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Middle@2x.png"; path = "Resources/Middle@2x.png"; sourceTree = "<group>"; };
30FE4159176A32C300F317B8 /* Single_Selected@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Single_Selected@2x.png"; path = "Resources/Single_Selected@2x.png"; sourceTree = "<group>"; };
30FE415A176A32C300F317B8 /* Single@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Single@2x.png"; path = "Resources/Single@2x.png"; sourceTree = "<group>"; };
5EA85FF11E7E458B98D5825C /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
E4370D63D1564228A75E7BD2 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -239,6 +218,7 @@
30EF93B316E039B800B84981 /* UIKit.framework in Frameworks */,
30EF93B516E039B800B84981 /* Foundation.framework in Frameworks */,
30EF93B716E039B800B84981 /* CoreGraphics.framework in Frameworks */,
53378ADE88FA40FD87184931 /* libPods.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -324,53 +304,6 @@
path = Photos;
sourceTree = "<group>";
};
30939CF517949B2D004D95A9 /* Vendor */ = {
isa = PBXGroup;
children = (
30B00D5017C56EEF0010D439 /* REValidation */,
30939CF617949B2D004D95A9 /* REFormattedNumberField */,
);
path = Vendor;
sourceTree = SOURCE_ROOT;
};
30939CF617949B2D004D95A9 /* REFormattedNumberField */ = {
isa = PBXGroup;
children = (
30939CF717949B2D004D95A9 /* REFormattedNumberField.h */,
30939CF817949B2D004D95A9 /* REFormattedNumberField.m */,
);
path = REFormattedNumberField;
sourceTree = "<group>";
};
30B00D5017C56EEF0010D439 /* REValidation */ = {
isa = PBXGroup;
children = (
30B00D5117C56EEF0010D439 /* NSError+REValidation.h */,
30B00D5217C56EEF0010D439 /* NSError+REValidation.m */,
30B00D5317C56EEF0010D439 /* REValidation.h */,
30B00D5417C56EEF0010D439 /* REValidation.m */,
30B00D5517C56EEF0010D439 /* REValidator.h */,
30B00D5617C56EEF0010D439 /* REValidator.m */,
30B00D5717C56EEF0010D439 /* Validators */,
);
path = REValidation;
sourceTree = "<group>";
};
30B00D5717C56EEF0010D439 /* Validators */ = {
isa = PBXGroup;
children = (
30B00D5817C56EEF0010D439 /* REEmailValidator.h */,
30B00D5917C56EEF0010D439 /* REEmailValidator.m */,
30B00D5A17C56EEF0010D439 /* RELengthValidator.h */,
30B00D5B17C56EEF0010D439 /* RELengthValidator.m */,
30B00D5C17C56EEF0010D439 /* REPresenceValidator.h */,
30B00D5D17C56EEF0010D439 /* REPresenceValidator.m */,
30B00DEC17D8E90D0010D439 /* REURLValidator.h */,
30B00DED17D8E90D0010D439 /* REURLValidator.m */,
);
path = Validators;
sourceTree = "<group>";
};
30DB064616E934AD006C9530 /* RETableViewManager */ = {
isa = PBXGroup;
children = (
@@ -453,6 +386,7 @@
30EF93B816E039B800B84981 /* RETableViewManagerExample */,
30EF93B116E039B800B84981 /* Frameworks */,
30EF93B016E039B800B84981 /* Products */,
E4370D63D1564228A75E7BD2 /* Pods.xcconfig */,
);
sourceTree = "<group>";
};
@@ -470,6 +404,7 @@
30EF93B216E039B800B84981 /* UIKit.framework */,
30EF93B416E039B800B84981 /* Foundation.framework */,
30EF93B616E039B800B84981 /* CoreGraphics.framework */,
5EA85FF11E7E458B98D5825C /* libPods.a */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -481,7 +416,6 @@
30EF93C216E039B800B84981 /* AppDelegate.m */,
302D2147170B25B10085654F /* Classes */,
30EF93B916E039B800B84981 /* Supporting Files */,
30939CF517949B2D004D95A9 /* Vendor */,
);
path = RETableViewManagerExample;
sourceTree = "<group>";
@@ -522,9 +456,11 @@
isa = PBXNativeTarget;
buildConfigurationList = 30EF93CC16E039B800B84981 /* Build configuration list for PBXNativeTarget "RETableViewManagerExample" */;
buildPhases = (
C91F9E51E3614E49887C24A5 /* Check Pods Manifest.lock */,
30EF93AB16E039B800B84981 /* Sources */,
30EF93AC16E039B800B84981 /* Frameworks */,
30EF93AD16E039B800B84981 /* Resources */,
F83E7E6735F94118B5022F1E /* Copy Pods Resources */,
);
buildRules = (
);
@@ -603,6 +539,39 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
C91F9E51E3614E49887C24A5 /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
F83E7E6735F94118B5022F1E /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
30EF93AB16E039B800B84981 /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -644,18 +613,10 @@
30D74554174EB4CA00D4C7C1 /* RETableViewOptionCell.m in Sources */,
30D9566C175E3C0200AB977E /* RetractableViewController.m in Sources */,
30FE4147176A306600F317B8 /* StylingViewController.m in Sources */,
30939CF917949B2D004D95A9 /* REFormattedNumberField.m in Sources */,
303D966817B7CCE300A418F3 /* XIBTestItem.m in Sources */,
303D966B17B7CCF800A418F3 /* XIBTestCell.m in Sources */,
303D967217B7CDE300A418F3 /* XIBTestViewController.m in Sources */,
30E5F50C17BBD163005CF1FE /* IndexedListViewController.m in Sources */,
30B00D5E17C56EEF0010D439 /* NSError+REValidation.m in Sources */,
30B00D5F17C56EEF0010D439 /* REValidation.m in Sources */,
30B00D6017C56EEF0010D439 /* REValidator.m in Sources */,
30B00D6117C56EEF0010D439 /* REEmailValidator.m in Sources */,
30B00DEE17D8E9CE0010D439 /* REURLValidator.m in Sources */,
30B00D6217C56EEF0010D439 /* RELengthValidator.m in Sources */,
30B00D6317C56EEF0010D439 /* REPresenceValidator.m in Sources */,
30B00D7A17C667A90010D439 /* ValidationsViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -732,6 +693,7 @@
};
30EF93CD16E039B800B84981 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = E4370D63D1564228A75E7BD2 /* Pods.xcconfig */;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "RETableViewManagerExample/RETableViewManagerExample-Prefix.pch";
@@ -745,6 +707,7 @@
};
30EF93CE16E039B800B84981 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = E4370D63D1564228A75E7BD2 /* Pods.xcconfig */;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "RETableViewManagerExample/RETableViewManagerExample-Prefix.pch";