bcgov / cas-obps

0 stars 0 forks source link

API: Handle data validation #248

Closed pbastia closed 3 months ago

pbastia commented 3 months ago

Description:

Ensure data passed to the API is valid. Examples may include checking data formats, data bounds, date ranges, upload sizes, valid table entries and other similar attributes.

How is the API validating the data passed in through the endpoints? I imagine this is highly dependent on how flexible the endpoints are?

@DataVillage are there any solutions you have in mind, or issues with the current implementation that you'd like to bring up?

My recommendation would be to do something like this https://www.django-rest-framework.org/api-guide/validators/. The basic idea is to put "validation logic in reusable components". There are some good examples in the above URL. Ideally validation logic will not be duplicated across different endpoints.

Acceptance Criteria:

Given I am a developer When I want to Then

Development Checklist:

Definition of Ready (Note: If any of these points are not applicable, mark N/A)

·Definition of Done (Note: If any of these points are not applicable, mark N/A)

Notes:

Dependencies

pbastia commented 3 months ago

Data validation:

pbastia commented 3 months ago

@Sepehr-Sobhani confirms this already exists!

Custom validators can be used for complex data types: example

@patriciarussellCAS @hannavovk closing this one