digital-preservation / csv-schema

CSV Schema
http://digital-preservation.github.io/csv-schema
Mozilla Public License 2.0
98 stars 33 forks source link

Conditional warning #28

Open afranke opened 5 years ago

afranke commented 5 years ago

The spec allows a validation rule to trigger a warning instead of an error, but it doesn’t allow for a given field to trigger an warning if a condition is met and an error in other cases.

To give a more concrete example of what I’m trying to achieve, a field I’m validating is an IMDb id for movies. They used to be strictly tt+ 7 digits, so anything else was invalid, but they recently introduced tt + 8 digits too. The latter is valid so it should not be an error, but it is fairly uncommon and may be suspicious (we had several cases of accidental extraneous characters in that field). I’d like to have an error for anything that is not tt + 7 or 8 digits, and warnings for tt + 8 digits.

DavidUnderdown commented 5 years ago

Thanks

I think this would be a fairly big change due to the way the warning mechanism is currently implemented (though I can see its utility), directives apply at the level of the whole test for a field, rather than individual parts of it. We've been rather short of developers so haven't been able to do much on the schema/validator recently so there is no definite date for a new revision of the schema language to be released I'm afraid, though I'll pencil this in for review under 1.2. If there's any chance you could come up with a formal proposal as a pull request to the CSV Schema Language, that would be helpful.

David