File tree 1 file changed +4
-1
lines changed
apple/InlineIOS/Onboarding 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -74,9 +74,12 @@ struct Email: View {
74
74
}
75
75
}
76
76
77
+ private let 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])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-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])+)\])"#
78
+
77
79
private func validateInput( ) {
78
80
errorMsg = " "
79
- isInputValid = !email. isEmpty && email. contains ( " @ " ) && email. contains ( " . " )
81
+ let emailPredicate = NSPredicate ( format: " SELF MATCHES %@ " , emailRegex)
82
+ isInputValid = !email. isEmpty && emailPredicate. evaluate ( with: email)
80
83
}
81
84
82
85
func submit( ) {
You can’t perform that action at this time.
0 commit comments