- ADD Url validation

- ADD TaxCode validation
This commit is contained in:
giuseppenuc committed 2015-09-07 11:18:33 +02:00
1 parent 3f41f57c5d
commit 6a414294dc
4 files changed
+25 -1

No files matched your search

+1 -1
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'
+4
View File
@@ -14,4 +14,8 @@
- (BOOL) isNumeric;
- (BOOL) isValidUrl;
- (BOOL) isValidTaxCode;
@end
+14
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
+6
View File
@@ -27,6 +27,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