| 2 | | I would definitely be in favor of removing the warning altogether, but I could live with an info level "warning" about "missing" 'none'. |
| | 2 | I would definitely be in favor of removing the warning altogether (and at minimum for splitting it up, as then I can ignore this validator rule while still having the validated part for any real error), but I could live with an info level "warning" about "Prefer 'none' over <nothing> for readability purposes". |
| | 3 | |
| | 4 | > On the other hand, I know that some users did misunderstand it and most of the issues of missing values (other rule) I find in the wild are caused by users removing the last | without any value after it. |
| | 5 | Which is what validation of `lanes=*` vs. the number of `|`s could help with. If desired, it's quite a large chunk (more suitable for Java I guess as then you can just loop over it): |
| | 6 | {{{ |
| | 7 | #!rule |
| | 8 | way[lanes=2][/.+:lanes$/=~/^[^\|]*$/], |
| | 9 | way[lanes=3][/.+:lanes$/=~/^([^\|]*\|){0,1}[^\|]*$/], |
| | 10 | way[lanes=4][/.+:lanes$/=~/^([^\|]*\|){0,2}[^\|]*$/], |
| | 11 | way[lanes=5][/.+:lanes$/=~/^([^\|]*\|){0,3}[^\|]*$/], |
| | 12 | way[lanes=6][/.+:lanes$/=~/^([^\|]*\|){0,4}[^\|]*$/], |
| | 13 | way[lanes=7][/.+:lanes$/=~/^([^\|]*\|){0,5}[^\|]*$/], |
| | 14 | way[lanes=8][/.+:lanes$/=~/^([^\|]*\|){0,6}[^\|]*$/], |
| | 15 | way[lanes=9][/.+:lanes$/=~/^([^\|]*\|){0,7}[^\|]*$/], |
| | 16 | way[lanes:forward=2][/.+:lanes:forward$/=~/^[^\|]*$/], |
| | 17 | way[lanes:forward=3][/.+:lanes:forward$/=~/^([^\|]*\|){0,1}[^\|]*$/], |
| | 18 | way[lanes:forward=4][/.+:lanes:forward$/=~/^([^\|]*\|){0,2}[^\|]*$/], |
| | 19 | way[lanes:forward=5][/.+:lanes:forward$/=~/^([^\|]*\|){0,3}[^\|]*$/], |
| | 20 | way[lanes:forward=6][/.+:lanes:forward$/=~/^([^\|]*\|){0,4}[^\|]*$/], |
| | 21 | way[lanes:forward=7][/.+:lanes:forward$/=~/^([^\|]*\|){0,5}[^\|]*$/], |
| | 22 | way[lanes:forward=8][/.+:lanes:forward$/=~/^([^\|]*\|){0,6}[^\|]*$/], |
| | 23 | way[lanes:forward=9][/.+:lanes:forward$/=~/^([^\|]*\|){0,7}[^\|]*$/], |
| | 24 | way[lanes:backward=2][/.+:lanes:backward$/=~/^[^\|]*$/], |
| | 25 | way[lanes:backward=3][/.+:lanes:backward$/=~/^([^\|]*\|){0,1}[^\|]*$/], |
| | 26 | way[lanes:backward=4][/.+:lanes:backward$/=~/^([^\|]*\|){0,2}[^\|]*$/], |
| | 27 | way[lanes:backward=5][/.+:lanes:backward$/=~/^([^\|]*\|){0,3}[^\|]*$/], |
| | 28 | way[lanes:backward=6][/.+:lanes:backward$/=~/^([^\|]*\|){0,4}[^\|]*$/], |
| | 29 | way[lanes:backward=7][/.+:lanes:backward$/=~/^([^\|]*\|){0,5}[^\|]*$/], |
| | 30 | way[lanes:backward=8][/.+:lanes:backward$/=~/^([^\|]*\|){0,6}[^\|]*$/], |
| | 31 | way[lanes:backward=9][/.+:lanes:backward$/=~/^([^\|]*\|){0,7}[^\|]*$/], |
| | 32 | way[lanes:both_ways=2][/.+:lanes:both_ways$/=~/^[^\|]*$/], |
| | 33 | way[lanes:both_ways=3][/.+:lanes:both_ways$/=~/^([^\|]*\|){0,1}[^\|]*$/], |
| | 34 | way[lanes:both_ways=4][/.+:lanes:both_ways$/=~/^([^\|]*\|){0,2}[^\|]*$/], |
| | 35 | way[lanes:both_ways=5][/.+:lanes:both_ways$/=~/^([^\|]*\|){0,3}[^\|]*$/], |
| | 36 | way[lanes:both_ways=6][/.+:lanes:both_ways$/=~/^([^\|]*\|){0,4}[^\|]*$/], |
| | 37 | way[lanes:both_ways=7][/.+:lanes:both_ways$/=~/^([^\|]*\|){0,5}[^\|]*$/], |
| | 38 | way[lanes:both_ways=8][/.+:lanes:both_ways$/=~/^([^\|]*\|){0,6}[^\|]*$/], |
| | 39 | way[lanes:both_ways=9][/.+:lanes:both_ways$/=~/^([^\|]*\|){0,7}[^\|]*$/] { |
| | 40 | throwWarning: tr("{0} is larger than the number of lanes in a *:lanes tag", "{0.tag}"); |
| | 41 | group: tr("eigen filters"); |
| | 42 | assertMatch: "way highway=primary oneway=yes lanes=2 bus:lanes=no"; |
| | 43 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no"; |
| | 44 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|no"; |
| | 45 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|"; |
| | 46 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|no|"; |
| | 47 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|no| turn:lanes=left|through|through|right"; |
| | 48 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no||"; |
| | 49 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=||no"; |
| | 50 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=yes|no"; |
| | 51 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|yes"; |
| | 52 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=yes|no|yes"; |
| | 53 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|yes|yes"; |
| | 54 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=yes|yes|no"; |
| | 55 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|yes|yes|yes"; |
| | 56 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|||"; |
| | 57 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|no||"; |
| | 58 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|||no"; |
| | 59 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|||no turn:lanes=left|through|through|right"; |
| | 60 | assertNoMatch: "way highway=primary oneway=yes lanes=4"; |
| | 61 | } |
| | 62 | way[lanes=1][/.+:lanes$/=~/\|/], |
| | 63 | way[lanes=2][/.+:lanes$/=~/^(.*\|){2}/], |
| | 64 | way[lanes=3][/.+:lanes$/=~/^(.*\|){3}/], |
| | 65 | way[lanes=4][/.+:lanes$/=~/^(.*\|){4}/], |
| | 66 | way[lanes=5][/.+:lanes$/=~/^(.*\|){5}/], |
| | 67 | way[lanes=6][/.+:lanes$/=~/^(.*\|){6}/], |
| | 68 | way[lanes=7][/.+:lanes$/=~/^(.*\|){7}/], |
| | 69 | way[lanes=8][/.+:lanes$/=~/^(.*\|){8}/], |
| | 70 | way[lanes=9][/.+:lanes$/=~/^(.*\|){9}/], |
| | 71 | way[lanes:forward=1][/.+:lanes:forward$/=~/\|/], |
| | 72 | way[lanes:forward=2][/.+:lanes:forward$/=~/^(.*\|){2}/], |
| | 73 | way[lanes:forward=3][/.+:lanes:forward$/=~/^(.*\|){3}/], |
| | 74 | way[lanes:forward=4][/.+:lanes:forward$/=~/^(.*\|){4}/], |
| | 75 | way[lanes:forward=5][/.+:lanes:forward$/=~/^(.*\|){5}/], |
| | 76 | way[lanes:forward=6][/.+:lanes:forward$/=~/^(.*\|){6}/], |
| | 77 | way[lanes:forward=7][/.+:lanes:forward$/=~/^(.*\|){7}/], |
| | 78 | way[lanes:forward=8][/.+:lanes:forward$/=~/^(.*\|){8}/], |
| | 79 | way[lanes:forward=9][/.+:lanes:forward$/=~/^(.*\|){9}/], |
| | 80 | way[lanes:backward=1][/.+:lanes:backward$/=~/\|/], |
| | 81 | way[lanes:backward=2][/.+:lanes:backward$/=~/^(.*\|){2}/], |
| | 82 | way[lanes:backward=3][/.+:lanes:backward$/=~/^(.*\|){3}/], |
| | 83 | way[lanes:backward=4][/.+:lanes:backward$/=~/^(.*\|){4}/], |
| | 84 | way[lanes:backward=5][/.+:lanes:backward$/=~/^(.*\|){5}/], |
| | 85 | way[lanes:backward=6][/.+:lanes:backward$/=~/^(.*\|){6}/], |
| | 86 | way[lanes:backward=7][/.+:lanes:backward$/=~/^(.*\|){7}/], |
| | 87 | way[lanes:backward=8][/.+:lanes:backward$/=~/^(.*\|){8}/], |
| | 88 | way[lanes:backward=9][/.+:lanes:backward$/=~/^(.*\|){9}/], |
| | 89 | way[lanes:both_ways=1][/.+:lanes:both_ways$/=~/\|/], |
| | 90 | way[lanes:both_ways=2][/.+:lanes:both_ways$/=~/^(.*\|){2}/], |
| | 91 | way[lanes:both_ways=3][/.+:lanes:both_ways$/=~/^(.*\|){3}/], |
| | 92 | way[lanes:both_ways=4][/.+:lanes:both_ways$/=~/^(.*\|){4}/], |
| | 93 | way[lanes:both_ways=5][/.+:lanes:both_ways$/=~/^(.*\|){5}/], |
| | 94 | way[lanes:both_ways=6][/.+:lanes:both_ways$/=~/^(.*\|){6}/], |
| | 95 | way[lanes:both_ways=7][/.+:lanes:both_ways$/=~/^(.*\|){7}/], |
| | 96 | way[lanes:both_ways=8][/.+:lanes:both_ways$/=~/^(.*\|){8}/], |
| | 97 | way[lanes:both_ways=9][/.+:lanes:both_ways$/=~/^(.*\|){9}/] { |
| | 98 | throwWarning: tr("{0} is smaller than the number of lanes in a *:lanes tag", "{0.tag}"); |
| | 99 | group: tr("eigen filters"); |
| | 100 | assertMatch: "way highway=primary oneway=yes lanes=1 bus:lanes=|no"; |
| | 101 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=||||no"; |
| | 102 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|||no|"; |
| | 103 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=||no||"; |
| | 104 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|no|||"; |
| | 105 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no||||"; |
| | 106 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=yes|yes|yes|yes|no"; |
| | 107 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=yes|yes|yes|no|yes"; |
| | 108 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=yes|yes|no|yes|yes"; |
| | 109 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=yes|no|yes|yes|yes"; |
| | 110 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|yes|yes|yes|yes"; |
| | 111 | assertMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|yes|yes|yes|yes turn:lanes=left|through|through|right"; |
| | 112 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|yes|yes|yes"; |
| | 113 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=no|||"; |
| | 114 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|no||"; |
| | 115 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|||no"; |
| | 116 | assertNoMatch: "way highway=primary oneway=yes lanes=4 bus:lanes=|||no turn:lanes=left|through|through|right"; |
| | 117 | assertNoMatch: "way highway=primary oneway=yes lanes=4"; |
| | 118 | } |
| | 119 | }}} |
| | 120 | But that's off-topic. Main point in my reply to this part is that a widely used syntax shouldn't be "forbidden", even if some users don't understand it (like many things: you have to learn it first). I guess TagInfo gives enough clues about the opinions of others? |