Em-Ant / fcc-options-app

Options Inc. web app development
Other
12 stars 7 forks source link

Editing vehicles max seats (or wheelchairs) can lead to wrong state #10

Closed Em-Ant closed 8 years ago

Em-Ant commented 8 years ago

Example: If you have 5 consumers on Van 1, and you edit that van properties setting maxSeats to 3, you get an incorrect state. Before editing we should check for state coherence, and if an incorrect situation is requested, we should abort the update maybe asking to remove the surplus consumers first.

andrealonzo commented 8 years ago

I will try to tackle this. I think this can be done by trying to figure out how the mongoose-id-validator plugin works.

andrealonzo commented 8 years ago

fixed via e30cb8e5fc9ee58dbc643e19ddefc06fc07f094c.

I added a pre validate schema middleware to invalidate the vehicle if consumers couldn't fit in the new vehicle configuration