statisticsnorway / ssb-datadoc-model

Data Model for use in SSB's Metadata system
MIT License
0 stars 1 forks source link

Forbid extra fields in Pydantic models #43

Closed mmwinther closed 8 months ago

mmwinther commented 8 months ago

By default, Pydantic allows extra fields to be set on model instantiation. This can lead to some very 🌶️ spicy 🌶️ bugs as a typo can prevent data being saved correctly, and this won't be picked up by any code quality tools.

This change will raise a ValidationError if an unknown field is set (see the unit test).