Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(prices): reorganise schema inheritance to validate price updates #342

Merged
merged 3 commits into from
Jun 27, 2024

Conversation

raphodn
Copy link
Member

@raphodn raphodn commented Jun 27, 2024

What

Currently we don't have any validation on PriceBasicUpdatableFields, so a user could add a negative price...
Related to this comment : openfoodfacts/openfoodfacts-dart#942 (comment)

How

  • new PriceBase schema
  • renamed PriceBasicUpdatableFields to PriceUpdate
  • made all fields of PriceUpdate optional (for the PATCH method)
  • added their WithValidation counterparts, to validation on creation/update, but skip on get (to speed up !)

Todo

It still doesn't validate the edition of the price_per field, because it relies on fields (product_code, category_tags) that are not available in the PriceBase schema... 🤔

Useful links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant