FROM : Richard Wolf
DATE : Fri Nov 30 21:30:26 2007
On Nov 30, 2007, at 4:24 AM, mmalc crawford wrote:
>
> On Nov 30, 2007, at 2:33 AM, Richard Wolf wrote:
>
>> "Normally" I'd be able to provide my own validation methods and
>> craft the NSErrors ... but this is Core Data ... and the object
>> model is doing the validation for me.
>>
> Why not just implement your own managed object validation methods?
Well, I've thought about that, I really have. Problem is this:
In the data modeling tool in XCode, I have my entity defined nice and
neat ... and the settings for my "sharedSecret" attribute are all
laid out ... including the "Reg. Ex." text string ...
[A-Z0-9]{32,32}
I aspire to be a good, lazy programmer ... let the data modeling tool
hang onto the regex if I can get away with it. But if I do that, the
only control I have over the error alert (short of doing a view/
window/doc delegate) is how the attribute name appears ... I can go
from "sharedSecret" to "Shared secret".
Now I'm more than happy to move that regex string into a
-(BOOL)validateSharedSecret:(id *)ioValue error:(NSError **)outError
method in my NSManagedObject subclass. But what I can't find is a
way to do this:
BOOL result = [*ioValue matchesRegularExpression:@"[A-Z0-9]{32,32}"];
At least, so far as I know, there is no Apple-approved way to do
that. I could glom onto another Cocoa regex class, but I thought
that ... somehow ... CoreData already knows how to do that ... so
I'll do the work if I have to, but if there is some way to do it
simply, I'd super-appreciative ("buy you a beer" appreciative) to
know how.
Thanks Malcolm!
DATE : Fri Nov 30 21:30:26 2007
On Nov 30, 2007, at 4:24 AM, mmalc crawford wrote:
>
> On Nov 30, 2007, at 2:33 AM, Richard Wolf wrote:
>
>> "Normally" I'd be able to provide my own validation methods and
>> craft the NSErrors ... but this is Core Data ... and the object
>> model is doing the validation for me.
>>
> Why not just implement your own managed object validation methods?
Well, I've thought about that, I really have. Problem is this:
In the data modeling tool in XCode, I have my entity defined nice and
neat ... and the settings for my "sharedSecret" attribute are all
laid out ... including the "Reg. Ex." text string ...
[A-Z0-9]{32,32}
I aspire to be a good, lazy programmer ... let the data modeling tool
hang onto the regex if I can get away with it. But if I do that, the
only control I have over the error alert (short of doing a view/
window/doc delegate) is how the attribute name appears ... I can go
from "sharedSecret" to "Shared secret".
Now I'm more than happy to move that regex string into a
-(BOOL)validateSharedSecret:(id *)ioValue error:(NSError **)outError
method in my NSManagedObject subclass. But what I can't find is a
way to do this:
BOOL result = [*ioValue matchesRegularExpression:@"[A-Z0-9]{32,32}"];
At least, so far as I know, there is no Apple-approved way to do
that. I could glom onto another Cocoa regex class, but I thought
that ... somehow ... CoreData already knows how to do that ... so
I'll do the work if I have to, but if there is some way to do it
simply, I'd super-appreciative ("buy you a beer" appreciative) to
know how.
Thanks Malcolm!
| Related mails | Author | Date |
|---|---|---|
| Richard Wolf | Nov 30, 03:33 | |
| mmalc crawford | Nov 30, 11:24 | |
| Richard Wolf | Nov 30, 21:30 | |
| Chris Hanson | Nov 30, 21:47 | |
| Richard Wolf | Nov 30, 22:09 |






Cocoa mail archive

