Re: Error validating email addresses in Core Data
Re: Error validating email addresses in Core Data
- Subject: Re: Error validating email addresses in Core Data
- From: Conrad Shultz <email@hidden>
- Date: Fri, 15 Apr 2011 08:15:28 -0700
I'm not a Core Data guru at all, but the regex you supplied will not match lower case letters. (My understanding is that Core Data string comparisons are case insensitive by default, but does this apply to regexes?)
In any case, be aware that there are many syntactically valid email addresses that will fail this test. A simple example: root@localhost
--
Conrad Shultz
www.synthetiqsolutions.com
On Apr 15, 2011, at 6:30, Michael Crawford <email@hidden> wrote:
> I'm trying to validate email addresses in Core Data but the regular expression I'm using doesn't seem to work even though it looks correct. I'm using the following expression:
>
> ^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$
>
> Which produces the following error:
>
> NSValidationErrorKey=email, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1680.), NSValidationErrorPredicate=SELF MATCHES "^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$", NSValidationErrorValue=email@hidden
>
> I'm pretty certain the expression is correct so I'm thinking there must be something I don't know about how to use it with Core Data. I'm inputing the expression in the MOM editor in Xcode 4, not coding to the APIs directly. In my code I'm calling -[NSManagedObject validateForInsert].
>
> If you've run into problems using regular expressions with Core Data and then found a solution or if you see some obvious problem with what I have here, I'd love to here from you.
>
> -Michael
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden