LibreCat / Catmandu

Catmandu - a data processing toolkit
https://librecat.org
175 stars 31 forks source link

Add new validator and Catmandu->validator method #335

Closed nichtich closed 6 years ago

nichtich commented 6 years ago

This includes some refactoring of Catmandu::Env which could be extended even further for stores.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.05%) to 94.548% when pulling 2ca57e5fe9351d46749d714460bed183b8dc516e on validator into 8a158839aae0da096f19d6172431369aa3f4a02e on dev.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.05%) to 94.548% when pulling 04f102ded74c6b5252b8118bb91bc4497ae342be on validator into 8a158839aae0da096f19d6172431369aa3f4a02e on dev.

nics commented 6 years ago

Commit 11c97a4 by @phochste should not be part of this pr.

nics commented 6 years ago

Randomly marking records as invalid doesn't seem very helpful for testing purposes. A Catmandu::Validator::Mock that marks records as invalid in a predictable manner would be very useful.

nichtich commented 6 years ago

Every validator that marks items as valid based on their content is not mocking but an actual validator. Such validators will be useful but you end up creating your own schema language. How about the alternative given in https://github.com/LibreCat/Catmandu/pull/338 with a default validator that only rejects if a given environment variable is set?

phochste commented 6 years ago

How about a Mock validator that throws and error is a string value is larger than N bytes? Or, throws an error when the error field is set? It is that in test environments (travis and all that) we don't want to depend on random behaviour of methods... the same input should give the same output.

nics commented 6 years ago

I'm adding a Mock validator that rejects based on a flag

nics commented 6 years ago

superseded by #338