mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
move email-validation to a common place
instead of c&p it - lazy bastard :-)
This commit is contained in:
@@ -106,21 +106,6 @@
|
||||
}
|
||||
|
||||
#pragma mark - Private methods
|
||||
|
||||
- (BOOL)validateEmail {
|
||||
NSString *emailRegex =
|
||||
@"(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}"
|
||||
@"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\"
|
||||
@"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-"
|
||||
@"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5"
|
||||
@"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"
|
||||
@"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21"
|
||||
@"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
|
||||
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES[c] %@", emailRegex];
|
||||
|
||||
return [emailTest evaluateWithObject:self.email];
|
||||
}
|
||||
|
||||
- (BOOL)allRequiredFieldsEntered {
|
||||
if ([self.manager requireUserName] == BITFeedbackUserDataElementRequired && [self.name length] == 0)
|
||||
return NO;
|
||||
@@ -128,7 +113,7 @@
|
||||
if ([self.manager requireUserEmail] == BITFeedbackUserDataElementRequired && [self.email length] == 0)
|
||||
return NO;
|
||||
|
||||
if ([self.email length] > 0 && ![self validateEmail])
|
||||
if ([self.email length] > 0 && !BITValidateEmail(self.email))
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
|
||||
Reference in New Issue
Block a user