mollie / mollie-api-python

Mollie API client for Python
http://www.mollie.com
BSD 2-Clause "Simplified" License
113 stars 55 forks source link

Validate POST/PATCH payloads for required data and correct formatting #274

Open whyscream opened 1 year ago

whyscream commented 1 year ago

The current client does not check POST/PATCH payloads at all, they're sent to the API as-is, and the API will validate the contents, possibly returning an error. We could apply basic checks on the payload before sending it to the Mollie API:

Example: for the Create Payment call, we could validate:

All of this could be validated easily using tools like pydantic, marshmallow or jsonschema. With local validation, we could provide the developer with better error messages than the API provides (not checked yet), and we avoid invalid calls to the API.