chiark / gitweb /
Detect a few more inconsistencies
[ypp-sc-tools.db-test.git] / pctb / Commods.pm
index b348c17812373ab72405c9eebdfd8a0a4c56c977..183eb9655607aaa5044d28c25b7c30e7e8241925 100644 (file)
@@ -292,6 +292,14 @@ sub check_tsv_line ($$) {
        $f =~ m/^(|0|[1-9][0-9]{0,5}|\>1000)$/ or &$bad_data("bad field $i");
        ($i % 2) or ($f !~ m/\>/) or &$bad_data("> in field $i price");
     }
+
+    foreach my $i (2,4) {
+       &$bad_data("price with no qty or vice versa (field $i)")
+           if length($v[$i]) xor length($v[$i+1]);
+    }
+    length($v[2]) or length($v[4]) or
+       &$bad_data("commodity entry with no buy or sell offer");
+    
     return @v;
 }