Problem with validation (reproducible with EventManager example)

  • Hi,

    I've got a problem with CoreData validation in my application, that I've
    verified against an example delivered by Apple. So it shouldn't be a problem to
    reproduce it for everyone:

    Steps to reproduce (example project "EventManager" in "CoreData"):
    1. Click on tab "Persons"
    2. Click on button "Add" -> a new empty line is inserted in the NSTableView
    3. Click again on button "Add" -> a second empty line is inserted in the
    NSTableView
    4. Click on the close button of the window -> EventManager asks to save the
    document.
    5. Try to save it -> lots of validation errors occurs.

    I think the validation should occur every time the user clicks on "Add", so it
    isn't possible to add a second empty line. I activated "validates immediately"
    for the value bindings of the columns, but it don't work.

    The example isn't user friendly this way, is it? And so is my application.

    Can someone help to implement the desired functionality?

    Marc
  • On Jun 3, 2006, at 11:57 AM, <gmc...> wrote:

    > I think the validation should occur every time the user clicks on
    > "Add", so it
    > isn't possible to add a second empty line. I activated "validates
    > immediately"
    > for the value bindings of the columns, but it don't work.
    >
    Validates Immediately applies to new values set using the UI element...
    If you allow your object to come into being in an invalid state, then
    it's up to you to remedy that.

    > Can someone help to implement the desired functionality?
    >
    It's up to you to determine what functionality you require.  Do you
    want to always deny a change in selection if the currently-selected
    item is invalid (you probably also want to disable the Add button
    until a newly-inserted object is valid)?  That could itself become
    frustrating...

    One option is to ensure that your new objects are valid on insertion,
    either by supplying suitable values on creation, or by -- for example
    -- using a sheet for new data entry (see <http://homepage.mac.com/
    mmalc/CocoaExamples/DepartmentAndEmployees2.zip
    >).

    mmalc
  • I just looked how it is implemened by Apple in iPhoto for the Keywords in the
    Preferences window:

    After inserting a row, you can't set the value to an empty string. I thought
    there should be an automatic and easy way to check that, before
    CoreData checks
    it when saving to the store.

    Marc

    >
    > On Jun 3, 2006, at 11:57 AM, <gmc...> wrote:
    >
    >> I think the validation should occur every time the user clicks on
    >> "Add", so it
    >> isn't possible to add a second empty line. I activated "validates
    >> immediately"
    >> for the value bindings of the columns, but it don't work.
    >>
    > Validates Immediately applies to new values set using the UI element...
    > If you allow your object to come into being in an invalid state, then
    > it's up to you to remedy that.
    >
    >> Can someone help to implement the desired functionality?
    >>
    > It's up to you to determine what functionality you require.  Do you
    > want to always deny a change in selection if the currently-selected
    > item is invalid (you probably also want to disable the Add button
    > until a newly-inserted object is valid)?  That could itself become
    > frustrating...
    >
    > One option is to ensure that your new objects are valid on insertion,
    > either by supplying suitable values on creation, or by -- for
    > example  -- using a sheet for new data entry (see
    > <http://homepage.mac.com/
    > mmalc/CocoaExamples/DepartmentAndEmployees2.zip>).
    >
    > mmalc
    >
    >
  • On Jun 3, 2006, at 12:27 PM, <gmc...> wrote:

    > After inserting a row, you can't set the value to an empty string.
    > I thought
    > there should be an automatic and easy way to check that, before
    > CoreData checks
    > it when saving to the store.

    As stated before, it's up to you to decide what validation to perform
    when.  You are free to invoke validation methods as and when you
    like.  "How to validate is a model decision, when to validate is a UI
    decision." (MP)

    mmalc
previous month june 2006 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today