- Add Numeric Validation
- Add Example
This commit is contained in:
parent
3a0cc86d5a
commit
3f41f57c5d
1
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
1
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
@ -595,6 +595,7 @@
|
|||||||
8A1E45814E2A2397A2C54120 /* Project object */ = {
|
8A1E45814E2A2397A2C54120 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
|
LastSwiftUpdateCheck = 0700;
|
||||||
LastUpgradeCheck = 0640;
|
LastUpgradeCheck = 0640;
|
||||||
};
|
};
|
||||||
buildConfigurationList = EAEFBFC1E6CD5EE912823F1F /* Build configuration list for PBXProject "Pods" */;
|
buildConfigurationList = EAEFBFC1E6CD5EE912823F1F /* Build configuration list for PBXProject "Pods" */;
|
||||||
|
|||||||
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
@interface NSString (Helper)
|
@interface NSString (Helper)
|
||||||
|
|
||||||
- (BOOL) validateEmail;
|
- (BOOL) isValidEmail;
|
||||||
|
|
||||||
|
- (BOOL) isNumeric;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
@implementation NSString (Helper)
|
@implementation NSString (Helper)
|
||||||
|
|
||||||
- (BOOL) validateEmail
|
- (BOOL) isValidEmail
|
||||||
{
|
{
|
||||||
BOOL stricterFilter = YES;
|
BOOL stricterFilter = YES;
|
||||||
NSString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
|
NSString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
|
||||||
@ -20,4 +20,12 @@
|
|||||||
return [emailTest evaluateWithObject:self];
|
return [emailTest evaluateWithObject:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isNumeric {
|
||||||
|
BOOL isValid = NO;
|
||||||
|
NSCharacterSet *alphaNumbersSet = [NSCharacterSet decimalDigitCharacterSet];
|
||||||
|
NSCharacterSet *stringSet = [NSCharacterSet characterSetWithCharactersInString:self];
|
||||||
|
isValid = [alphaNumbersSet isSupersetOfSet:stringSet];
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
11
README.md
11
README.md
@ -17,7 +17,16 @@ NSString-Helper is available through [CocoaPods](http://cocoapods.org). To insta
|
|||||||
it, simply add the following line to your Podfile:
|
it, simply add the following line to your Podfile:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
pod "NSString-Helper"
|
pod 'NSString-Helper' , :git => 'https://github.com/giuseppenucifora/NSString-Helper.git'
|
||||||
|
```
|
||||||
|
##Usage
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
NSString *str = @"testCode";
|
||||||
|
|
||||||
|
NSLog(@"%@",[NSNumber numberWithBool:[str isNumeric]]);
|
||||||
|
|
||||||
|
NSLog(@"%@",[NSNumber numberWithBool:[str isValidEmail]]);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user