←back to thread

Parse, Don't Validate (2019)

(lexi-lambda.github.io)
389 points melse | 1 comments | | HN request time: 0.218s | source
Show context
Attummm ◴[] No.27640130[source]
That's how the validation tool for Python Maat works. By creating a completely new dictionary. https://github.com/Attumm/Maat
replies(2): >>27640197 #>>27640762 #
mulmboy ◴[] No.27640762[source]
How does Maat compare with pydantic? https://github.com/samuelcolvin/pydantic
replies(2): >>27640874 #>>27640983 #
rmnclmnt ◴[] No.27640874[source]
If only for conciseness, readability and speed, I'd take Pydantic over any day. Being able to express 80% of type checking using Python native type hints + dataclasses is just so intuitive!

And it's getting some wide adoption, for instance FastAPI which uses it for request validations.

replies(1): >>27641020 #
Attummm ◴[] No.27641020[source]
Engineering is about tradeoffs, even though both projects do validation.

The points you made are all very valid points.

At my employer we use both projects. If the data is very nested, or really large Maat is used.

replies(1): >>27641056 #
1. rmnclmnt ◴[] No.27641056[source]
Mmmh interesting requirement! Indeed, defining very nested structure with Pydantic is one of its weaknesses.

And of course I agree 100% about tradoffs in engineering. However I usually advise against using 2 dependencies doing mainly the same thing if possible within the same project.

Anyway, good catch, thanks for enlightening me!