Closed yolile closed 1 month ago
@jpmckinney I will add some tests and the translations after your review
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
app/dependencies.py | 2 | 3 | 66.67% | ||
app/mail.py | 1 | 3 | 33.33% | ||
<!-- | Total: | 14 | 17 | 82.35% | --> |
Totals | |
---|---|
Change from base Build 11386165049: | -0.1% |
Covered Lines: | 1748 |
Relevant Lines: | 2033 |
I think there is no more logic associated with additional_comments right? If so, we can remove that from frontend and backend.
I think so, yes, will remove it
Not sure if you saw my question:
What does the incoming JSON look like? Is the field just blank (empty string) or is it missing?
In any case, can you try with
from pydantic import condecimal
disbursed_final_amount: condecimal(gt=0)
Edit: I think the issue is that when not using "strict" mode then Pydantic does coercion, which in this case is assigning 0. However, since we are parsing JSON, I am not sure if setting strict=True
on the model/field will just cause new issues; gt=0
seems the safest option. https://docs.pydantic.dev/latest/concepts/strict_mode/
What does the incoming JSON look like? Is the field just blank (empty string) or is it missing?
I'm writing the tests and Pydantic is indeed working as expected so it seems the front end is sending 0 as the default value.
condecimal(gt=0)
I tested it now and this covers all cases, so I will use that instead. Could you remind me how we translate pydantic error messages?
Never mind, I will add the validation and message in the front end
The validation was excluded in the front end because https://github.com/open-contracting/credere-backend/pull/433#discussion_r1806415839
closes #427 closes #375