Results 1 to 4 of 4

Thread: .validate() doesn't test un-saved fields of a retrieved model

    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1220 in a recent build.
  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    134
    Vote Rating
    1
      0  

    Default .validate() doesn't test un-saved fields of a retrieved model

    If I set properties via the set method on a model, they don't get picked up immediately for validation. To workaround this, I'm creating a dummy model that I don't save with the same properties. This shouldn't be necessary.

    For example, this always fails with a 'unique' validation:
    Code:
        var currentModel = getCurrentModel();
        currentModel.set('name', newName);
        var errors = currentModel.validate();
        if (!errors.isValid()) {
             error();
        }
        else {
            currentModel.save();
        }
    I have to use this workaround:
    Code:
        var currentModel = getCurrentModel();
        currentModel.set('name', newName);
        var testModel = Ext.create('MyModel', {name:newName});
        var errors = testLiftModel.validate();
        if (!errors.isValid()) {
             error();
        }
        else {
            currentModel.save();
        }

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Thank you for the report.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    11
      0  

    Default

    This seems to have been fixed in the next release (Beta) as I'm not able to reproduce this bug. Please let us know if you still encounter this issue after the beta release.

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    134
    Vote Rating
    1
      0  

    Cool

    I likely won't test this until the final release, or the first patch after, given my experience trying to port to PR3, but if this is still in issue an whatever release I eventually migrate to, my automated tests will catch it and I'll re-file a report.

    I feel good that you couldn't reproduce the problem in the beta, though. This gives me hope for a smoother migration next time!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •