• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EOAttribute.validateValue question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOAttribute.validateValue question


  • Subject: Re: EOAttribute.validateValue question
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 11 Jul 2007 17:57:31 -0700


On Jul 11, 2007, at 5:35 PM, Francis Labrie wrote:

Hi,

Kieran Kelleher wrote:
As we know this EOAttribute.validateValue(...) gets called before custom eo validate<AttributeName> methods and it uses the class description to validate and/or do basic conversion. What are the alternatives to find an elegant way to call my custom validate first or is there none?

Why do I want to do this? I am importing text data from CSV files and pushing the text values into attributes in an efficient way, however I can easily handle conversion of YES/NO, T/F, Y/N, Y/null or TRUE/FALSE strings to Boolean in my custom validate<BooleanAttribute> methods, but of course EOF gets a shot at it first when I iterate through the imported values calling eo.validateTakeValueForKeyPath(aValue, aKey);

I have an alternative in mind, but just wanted to check with the smart folks first .... any suggestions?


I would personally avoid such solution: it breaks the normal EOF validation process, and you can potentially have to write lot of repetitive "validate<Attribute>" methods...

I agree. I have extended the coercion during validation a bit, but this seems like a Bad Idea (tm). :-)



A more generic and reusable solution would be to write CSVReader that takes a file reference, an array of key paths and an array of formatters to read CSV column strings, convert them if needed (with formatter) and set it (with key path and Key Value Coding). I've done this kind of thing in the past, and it's very handy. You can even create custom formatters to convert strings to special data (i.e. BooleanFormat, InetAddressFormat, etc.).

Interesting, that is precisely what I was about to suggest. I do the exact same thing. We must therefor be correct. Grin. It is definitely a more flexible solution and a better design for the problem at hand.



Chuck

--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: EOAttribute.validateValue question
      • From: Kieran Kelleher <email@hidden>
References: 
 >EOAttribute.validateValue question (From: Kieran Kelleher <email@hidden>)
 >Re: EOAttribute.validateValue question (From: Francis Labrie <email@hidden>)

  • Prev by Date: Re: EOAttribute.validateValue question
  • Next by Date: Re: EOAttribute.validateValue question
  • Previous by thread: Re: EOAttribute.validateValue question
  • Next by thread: Re: EOAttribute.validateValue question
  • Index(es):
    • Date
    • Thread