inbo / whip

✅ Human and machine-readable syntax to express specifications for data
MIT License
7 stars 0 forks source link

Priority of the `empty` test validation #3

Open stijnvanhoey opened 7 years ago

stijnvanhoey commented 7 years ago

The empty test is prior to all other tests, as it makes little sense to test for any other test when the field is just an empty string. Hence, this test aborts the other tests on a value when an empty string is encountered. It will simplify the implementation, as the other tests do not have to take into account the possibility of getting an empty string as input value. it will also diminish processing time (all empty values are faster evaluated with just a single test).

However, this has a major drawback as well:

When a conditional test is added (if) that includes the specification to decide when empty strings are allowed or not, this model runs into trouble. It requires to add a general empty test as well (empty is - sometimes - possible) and the priority of the empty test will stop the other tests, i.e. the if test is never started.

Therefore, we could decide about having the empty-test not as first priority test. This should be balanced against:

peterdesmet commented 7 years ago

Can you provide a commented example of this situation? Would be helpful to understand the issue.