23andMe / Yamale

A schema and validator for YAML.
MIT License
681 stars 89 forks source link

Adding custom validators support #9

Closed lionel-panhaleux closed 9 years ago

lionel-panhaleux commented 9 years ago

Hi,

My name is Lionel and I'm working at a french firm called Polyconseil. I found your yamale library the other day, and it is really well made. Yamale could be very useful for our new YAML configuration architecture. I took the liberty to make this pull request to add a feature we need : the ability to add some custom validators to the default yamale validators. I used a pretty simple "date" validator for testing purpose, but we have other custom format we would like to validate, which can not be added to the default validators because they are not so standard. I hope I'll have the opportunity to make some other PRs in the near future to help and improve this nice tool.

Kind Regards

blopker commented 9 years ago

Hey Lionel, I'm the creator/primary maintainer for this project. I'm on vacation right now, but I took a look at your changes and I like your approach. I'll be back in the office tomorrow and dig a little deeper. We use this library for several fundamental parts of our infrastructure so I have to be careful with any changes.

Cheers!

lionel-panhaleux commented 9 years ago

Hi blopker, no problem, there is no urgency on our side, we'll just use our fork for now ;-) Keep me up to date !

blopker commented 9 years ago

OK, I checked out your changes and moved some stuff around: https://github.com/23andMe/Yamale/commit/8110e6136bf7adc9f7718bf6b18e913d036dec08

The main change was to allow the TestCase class to use custom validators. Also, you should never use mutable objects (lists, dicts) as a default args in Python. Unless you are doing some recursion tricks it usually ends up confusing you later :)

lionel-panhaleux commented 9 years ago

Thanks for the merge ! Good point on the mutable default, too, I concur :-) I hope to be able to contribute some more soon.