This commit is contained in:
Giuseppe Nucifora 2015-10-29 02:43:23 +01:00
commit f7d44f55b6
4 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "NSString-Helper"
s.version = "0.1.1"
s.version = "1.0.0"
s.summary = "NSString-Helper is usefull helper to validate email NSString"
s.homepage = "https://github.com/giuseppenucifora/NSString-Helper"
s.license = 'MIT'

View File

@ -14,4 +14,8 @@
- (BOOL) isNumeric;
- (BOOL) isValidUrl;
- (BOOL) isValidTaxCode;
@end

View File

@ -28,4 +28,18 @@
return isValid;
}
- (BOOL) isValidUrl {
NSString *urlRegEx =
@"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";
NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx];
return [urlTest evaluateWithObject:self];
}
- (BOOL) isValidTaxCode {
NSString *urlRegEx = @"^[A-Z]{6}[A-Z0-9]{2}[A-Z][A-Z0-9]{2}[A-Z][A-Z0-9]{3}[A-Z]$";
NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx];
return [urlTest evaluateWithObject:self];
}
@end

View File

@ -31,6 +31,12 @@ NSString *str = @"testCode";
NSLog(@"%@",[NSNumber numberWithBool:[str isNumeric]]);
NSLog(@"%@",[NSNumber numberWithBool:[str isValidEmail]]);
NSLog(@"%@",[NSNumber numberWithBool:[str isValidUrl]]);
NSLog(@"%@",[NSNumber numberWithBool:[str isValidTaxCode]]);
```
## Author