romaricdrigon / MetaYaml

A powerful schema validator!
MIT License
104 stars 21 forks source link

Aggregate errors? #8

Closed dantleech closed 10 years ago

dantleech commented 10 years ago

Hi,

Is it possible to aggregate the errors messages then throw an exception instead of the first one?

romaricdrigon commented 10 years ago

Hello,

At the moment its not possible in the library. Adding it is possible, it requires (only) a little coding.

At the moment, NodeValidatorExceptions are thrown all around NodeValidators. Instead we could instead introduce add a raiseError method in the SchemaValidator, requiring something like a NodeValidatorError object. Each node has access to the SchemaValidator, so it can call this method. It can then decide what to do. Making configurable either to die with an exception on the first error or to report an array of all errors would be supra-nice.

dantleech commented 10 years ago

ok, I will probably have a good at doing that at some point then, thanks for the library :)

romaricdrigon commented 10 years ago

At the moment I'm closing the issue, feel free to ask if anything else & send a PR when ready :)