digital-preservation / csv-schema

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

A proper logical NOT operator #32

Open crizzis opened 4 years ago

crizzis commented 4 years ago

AFAIK Currently, the only way to express a negative rule is via the @matchIsFalse directive.

This means the entire column rule must be expressed either as a positive or a negative condition, and mixing positive and negative conditions (e.g. regex("[A-Z]+") and not(starts($another_column))) is not possible.

It would, therefore, be quite nice if a logical NOT operation was available that could invert the logic of arbitrary column validation expressions.

DavidUnderdown commented 4 years ago

By De Morgan's laws you could equivalently express that as

regex("[^A-Z]+") or starts($another_column) @matchIsFalse

though I agree that the representation with not is preferable (and this work around wouldn't apply in all cases, it only works for this example due to the availability of the negation operator in regex), so I'll label this as an enhancement request.