REST API request payload validator as a decorator

Sammy Wen

Sammy Wen

Software Engineer II @ Nylas. Currently in Vancouver, BC, Canada. My 5-year journey in Python is awesome! So glad to see the community keeps growing!

    摘要

    Developers often mess up the validation steps of the payloads from API requests. Following a systematic way to setup the validator and keep code clean is crucial. A decorator is a function that takes another function as an argument and extends its behavior without explicitly modifying it. Validator-as-a-decorator is an ideal approach for function-based APIs since the validation always happens before the API call happens. It is also reusable and prevent the need of changing the API implementation itself. In this talk, I'll first use a Flask (web framework) + Cerberus (3rd-party data validation library) example to demo the steps of building a Validator-as-a-decorator. The other part of the talk, I'll compare different data validation library in both functionality and restriction aspects, also briefly mention how other web frameworks (Django/FastAPI) deal with request payload validation.

    說明

    影片

    地點

    R1

    時間

    第一天 • 12:55-13:25 (GMT+8)

    語言

    英文演講

    層級

    中階

    分類

    Python 核心