graphiti-api/spraypaint.js

validation-error-builder assigns errors to the wrong list element

Closed this issue · 0 comments

Hello you wonderful people,

I found an error in the validation-error-builder in Line 74. The error can be summarised as such:

  1. We have an author with two books added via a hasMany relationship. All three models are already persisted and have an id. book.title must be a non-empty string.
  2. We set the title of the second book in the list to an empty string and save the book via the author (nested write).
  3. The validation error will now be added to the first book in the list, because it has no tempId and neither has the server response. So Line 74 will always evaluate
    r.temp_id === meta["temp-id"]
    to
    undefined === undefined.

I'll submit a PR with a test case right away. :)