News for hackers. Stuff that matters.
Re:Parse, Don't Validate (2019) by Attummm on Saturday June 26, 2021 @04:18AM (#27640130)
That's how the validation tool for Python Maat works. By creating a completely new dictionary. https://github.com/Attumm/Maat
Re:Parse, Don't Validate (2019) by errnesto on Saturday June 26, 2021 @04:33AM (#27640197)
For js / typescript I like: https://github.com/paperhive/fefe

basically ist’s just functions that take a value of one type and return a other one

Re:Parse, Don't Validate (2019) by vorticalbox on Saturday June 26, 2021 @06:59AM (#27640857)
There is also joi, zod, myzod just to name a few.

I personally use myzod as its fast it parsing, zero dependancies and you can infre types from your schemas.

Re:Parse, Don't Validate (2019) by catlifeonmars on Saturday June 26, 2021 @10:38AM (#27642240)
Re:Parse, Don't Validate (2019) by mulmboy on Saturday June 26, 2021 @06:34AM (#27640762)
How does Maat compare with pydantic? https://github.com/samuelcolvin/pydantic
Re:Parse, Don't Validate (2019) by Attummm on Saturday June 26, 2021 @07:26AM (#27640983)
Pydantic is using classes and typehinting. The new dataclasses style. Currently Maat doens't have a parser for dataclasses, it could come in the future. Pydantic works great with typehinting.

Maat was created before dataclasses existed. For validation Maat offers the same. But it also allows for some really neat features such as validation on encrypted data. https://github.com/Attumm/Maat/blob/main/tests/test_validati...

Since validation is written as dictionaries its possible to store the validations in caching db such as Redis.

And since its simple its easy to extend for anyone use case. And there are no other dependencies.

Benchmarks of pydantic has Maat around twice as Pydantic.

Re:Parse, Don't Validate (2019) by Attummm on Saturday June 26, 2021 @05:50PM (#27646242)
Unable to change my comment.

Benchmarks of pydantic has Maat around twice the speed of Pydantic

Re:Parse, Don't Validate (2019) by rmnclmnt on Saturday June 26, 2021 @07:03AM (#27640874)
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.

Re:Parse, Don't Validate (2019) by Attummm on Saturday June 26, 2021 @07:34AM (#27641020)
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.

Re:Parse, Don't Validate (2019) by rmnclmnt on Saturday June 26, 2021 @07:42AM (#27641056)
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!