I am simply trying to validate an email using an expression. I have created a Struct that I use for my form fields.
let emailRegEx = "[A-ZO-9a-z._%+-]+@[A-Za-zO-9.-J+|l.[A-Za-z]{2,64}"
var isEmailValid: Bool {
!email.isEmpty &&
if email.ranges(of: emailRegEx, options: .regularExpression) == nil {
return self
}
}
It keeps throwing this error...Cannot infer contextual base in reference to member 'regularExpression', and Expected expression after operator, lastly Extra argument 'options' in call.