News for hackers. Stuff that matters.
Re:Show HN: PySchemes – A library for validating data struct... by fermigier on Sunday November 05, 2017 @08:43AM (#15629324)
Re:Show HN: PySchemes – A library for validating data struct... by shazzy on Sunday November 05, 2017 @09:14AM (#15629459)
Also a shameless plug for my python library for declarative multi-field validation:

https://github.com/shezadkhan137/required

It makes it easier to expresses complex inter-field validation rules, and is meant to be used with other validation libraries.

Re:Show HN: PySchemes – A library for validating data struct... by willvarfar on Sunday November 05, 2017 @12:00PM (#15630264)
May I join you in shameless plugging? My own obiwan:

https://pypi.python.org/pypi/obiwan

It predates the MyPy syntax and, in my opinion, is a gazillion times prettier and my "pythonic". I'm not bitter ;)

It's "actively maintained" but I haven't needed to do anything in ages - it just works :)

PySchemes seems to have very similar syntax, but obiwan is also able to validate signatures in function annotations and is particularly good at validating JSON and msgpack APIs (the python code to validate an API is self-describing and makes excellent API documentation for other parties).

Re:Show HN: PySchemes – A library for validating data struct... by chucksmash on Sunday November 05, 2017 @11:18AM (#15630040)
It looks similar to voluptuous. Browsing READMEs, the other three examples expose their own library level representations for primitive types (e.g. Field.int() or {"type": "int"} instead of the primitive Python type int).
Re:Show HN: PySchemes – A library for validating data struct... by xapata on Sunday November 05, 2017 @02:53PM (#15631219)
https://github.com/selik/destructure

Similar design to Voluptuous, but it also supports a destructuring bind instead of just validation.

Re:Show HN: PySchemes – A library for validating data struct... by carapace on Sunday November 05, 2017 @06:51PM (#15632513)
Re:Show HN: PySchemes – A library for validating data struct... by BerislavLopac on Sunday November 05, 2017 @03:08PM (#15631294)
Re:Show HN: PySchemes – A library for validating data struct... by fermigier on Sunday November 05, 2017 @08:51AM (#15629351)
Even more interesting projects here:

- https://awesome-python.com/#data-validation

Re:Show HN: PySchemes – A library for validating data struct... by logronoide on Sunday November 05, 2017 @09:19AM (#15629487)
Why is better PySchemes than others like Voluptuous? I’m happy with it, but open to new stuff.
Re:Show HN: PySchemes – A library for validating data struct... by StavrosK on Sunday November 05, 2017 @09:43AM (#15629594)
My preferred library is "schema", as it's very functional.
Re:Show HN: PySchemes – A library for validating data struct... by sametmax on Sunday November 05, 2017 @08:41AM (#15629316)
Everytime i see one of those i always wonder if they heard of marshmallow. I mean it's like creating a requests competitor really. It's an interesting exercice but the chances to be relevant are very low.
Re:Show HN: PySchemes – A library for validating data struct... by houzi on Sunday November 05, 2017 @09:05AM (#15629408)
I wasn't impressed. Couldn't figure out how to do complex validation of a JSON object, based on the input of another JSON object.
Re:Show HN: PySchemes – A library for validating data struct... by sametmax on Sunday November 05, 2017 @03:58PM (#15631524)
I read your comment like somebody saying he is not impressed by this bus that helps the whole town going to the office because he couldn't figure how to do nascar with it.
Re:Show HN: PySchemes – A library for validating data struct... by aldanor on Monday November 06, 2017 @07:22AM (#15634943)
Marshmallow doesn't suppport some trivial constructs like nested dicts, and isn't likely to: https://github.com/marshmallow-code/marshmallow/issues/483

To me, that's a complete showstopper.

Re:Show HN: PySchemes – A library for validating data struct... by mathgenius on Sunday November 05, 2017 @08:59AM (#15629388)
The great thing about python is it's so easy to roll your own. And people start thinking they are a genius or something. Ha :-)
Re:Show HN: PySchemes – A library for validating data struct... by shivylp on Sunday November 05, 2017 @09:02AM (#15629400)
No one's thinking that. Oh wait. Look at the username !
Re:Show HN: PySchemes – A library for validating data struct... by craigds on Sunday November 05, 2017 @11:32PM (#15633455)
marshmallow: 62 watchers, 2055 stars, 244 forks. requests: 1142 watchers, 28420 stars, 5212 forks.

I don't think those are in the same league

Re:Show HN: PySchemes – A library for validating data struct... by vram22 on Sunday November 05, 2017 @09:23AM (#15629507)
There is also jsonschema:

https://pypi.python.org/pypi/jsonschema

A post showing a simple use of it:

Using JSON Schema with Python to validate JSON data:

https://jugad2.blogspot.in/2015/12/using-json-schema-with-py...

Re:Show HN: PySchemes – A library for validating data struct... by ansgri on Sunday November 05, 2017 @02:24PM (#15631061)
Exactly my thought about json-schema, as I use it extensively in both Python and C++ (excellent library valijson [0]).

Not all Python objects are json-serializable by default, so the ideal solution (for me) would be json-schema with simple syntax for adding custom type validators.

[0] https://github.com/tristanpenman/valijson

Re:Show HN: PySchemes – A library for validating data struct... by vram22 on Sunday November 05, 2017 @05:29PM (#15632098)
Thanks for the info.
Re:Show HN: PySchemes – A library for validating data struct... by Dowwie on Sunday November 05, 2017 @09:46AM (#15629613)
Check out typeguard: https://github.com/agronholm/typeguard

it offers run-time type checking in a variety of ways, is intuitive, and actively maintained

Re:Show HN: PySchemes – A library for validating data struct... by StavrosK on Sunday November 05, 2017 @09:52AM (#15629643)
Is static checking with mypy just as good, faster and more timely?
Re:Show HN: PySchemes – A library for validating data struct... by rcthompson on Sunday November 05, 2017 @10:16AM (#15629761)
They're not mutually exclusive. Static type checking is fine if you can cover all your code with it, but it doesn't enforce anything at runtime. If you're writing a library that will be called by other people's code (which likely won't be statically type-checked), it might still be useful to validate your functions' inputs at runtime.
Re:Show HN: PySchemes – A library for validating data struct... by StavrosK on Sunday November 05, 2017 @10:25AM (#15629798)
True, and I guess it helps for when your non-validated code calls validated code. Odd how we've come around to realizing the importance of types and contracts after years of dynamic typing.

It's a bit like document databases, people are starting to realize again how convenient relational databases and how helpful schemas are.

Re:Show HN: PySchemes – A library for validating data struct... by rcthompson on Sunday November 05, 2017 @01:44PM (#15630856)
To be a little more clear, in a language where static typing was mandatory, there would obviously be no need for dynamic type checking of those same types. But since Python's static typing is optional, dynamic type checking at runtime is not redundant.
Re:Show HN: PySchemes – A library for validating data struct... by varlock on Sunday November 05, 2017 @09:19AM (#15629482)
Maybe I'm missing something, but IMO using isinstance, issubclass and explicit checks achieves the same effect, and is probably more readable. Or not?
Re:Show HN: PySchemes – A library for validating data struct... by gh02t on Sunday November 05, 2017 @10:48AM (#15629893)
It's tedious if you wanna validate a complex structure. Most of these libraries are meant to validate stuff that is user input. Imagine I load a complex input from a configuration file into a nested dict and checking it, that'd be really tedious to do manually. A couple checks here or there are ok, but they get confusing and difficult to maintain very quickly. Stuff like optional values, enumerated values etc are also not much fun.

Also error messages for the user. I've mostly used Voluptuous, but it provides much easier to understand error messages.

Re:Show HN: PySchemes – A library for validating data struct... by jdipierro on Sunday November 05, 2017 @09:19AM (#15629485)
I'm surprised to not see Formencode's validation on any of these lists: http://www.formencode.org/en/latest/Validator.html
Re:Show HN: PySchemes – A library for validating data struct... by crdoconnor on Sunday November 05, 2017 @09:51AM (#15629641)
If you want to validate YAML and want line numbers and code snippets in your errors, I wrote this:

http://github.com/crdoconnor/strictyaml

Re:Show HN: PySchemes – A library for validating data struct... by w_t_payne on Sunday November 05, 2017 @08:54AM (#15629361)
I really like 'voluptuous' (and its' ungoogleable fork; 'good')
Re:Show HN: PySchemes – A library for validating data struct... by bitexploder on Sunday November 05, 2017 @09:44AM (#15629607)
Seconded. It works and let's you build rules declaratively.
Re:Show HN: PySchemes – A library for validating data struct... by nolite on Sunday November 05, 2017 @09:41AM (#15629584)
does anyone know of something like this for ruby?
Re:Show HN: PySchemes – A library for validating data struct... by ezekg on Sunday November 05, 2017 @11:18AM (#15630035)
I wrote something similar for Ruby/Rails parameter validation. All of the solutions that were around at the time weren’t what I was looking for. It ends up looking like: https://gist.github.com/ezekg/f525a9d006c97cbcba231aa43e5ac9.... Is that something people would be interested in me open sourcing?
Re:Show HN: PySchemes – A library for validating data struct... by souenzzo on Sunday November 05, 2017 @09:58AM (#15629674)
Looks like clojure spec.