Changeset 17934 in josm for trunk/resources


Ignore:
Timestamp:
2021-06-21T17:32:59+02:00 (3 years ago)
Author:
Klumbumbus
Message:

Fix #21026, see #14532 - Better warnings for negative numeric values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/resources/data/validator/numeric.mapcss

    r17268 r17934  
    2929}
    3030
    31 *[building:levels][building:levels !~ /^(([0-9]|[1-9][0-9]*)(\.5)?)$/],
     31/* negative values, #21026 */
     32*[building:levels^="-"] {
     33  throwError: tr("negative {0} value", "{0.key}");
     34  set negative_value;
     35  assertMatch: "node building:levels=-1";
     36  assertNoMatch: "node building:levels=+1";
     37  assertNoMatch: "node building:levels=1";
     38  assertNoMatch: "node building:levels=foo";
     39  assertMatch: "node building:levels=-foo";
     40  assertNoMatch: "node level=-1";
     41}
     42
     43*[building:levels][building:levels !~ /^(([0-9]|[1-9][0-9]*)(\.5)?)$/]!.negative_value,
    3244*[level][level !~ /^((((-*[1-9]|[0-9])|-*[1-9][0-9]*)(\.5)?)|-0\.5)(;((((-*[1-9]|[0-9])|-*[1-9][0-9]*)(\.5)?)|-0\.5))*$/] { /* all numbers from -∞ to ∞ in 0.5 steps, optional multiple values separated by a ; */
    3345  throwWarning: tr("{0} should have numbers only with optional .5 increments", "{0.key}");
     
    223235*[width        ][width !~ /^(([0-9]+(\.[0-9]+)?( (m|ft))?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!.width_separator_autofix!.width_meter_autofix!.width_foot_autofix,
    224236*[maxwidth  ][maxwidth !~ /^(([0-9]+(\.[0-9]+)?( (m|ft))?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!.maxwidth_separator_autofix!.maxwidth_meter_autofix!.maxwidth_foot_autofix {
    225   throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");
     237  throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "meters");
    226238  assertMatch: "node height=medium";
    227239  assertMatch: "node maxheight=-5";
     
    269281*[maxaxleload][maxaxleload !~ /^([0-9]+(\.[0-9]+)?( (t|kg|st|lbs))?)$/]!.maxaxleload_separator_autofix,
    270282*[maxweight][maxweight !~ /^([0-9]+(\.[0-9]+)?( (t|kg|st|lbs))?)$/]!.maxweight_separator_autofix {
    271   throwWarning: tr("unusual value of {0}: tonne is default; point is decimal separator; if units, put space then unit", "{0.key}");
     283  throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "tonne");
    272284  assertMatch: "node maxaxleload=something";
    273285  assertMatch: "node maxweight=-5";
     
    280292way[maxspeed:forward][maxspeed:forward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
    281293way[maxspeed:backward][maxspeed:backward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/] {
    282   throwWarning: tr("unusual value of {0}", "{0.key}");
     294  throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "km/h");
    283295  assertMatch: "way maxspeed=something";
    284296  assertMatch: "way maxspeed=-50";
     
    307319}
    308320*[distance][distance !~ /^(([0-9]+(\.[0-9]+)?( (m|km|mi|nmi))?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!.distance_separator_autofix {
    309   throwWarning: tr("unusual value of {0}: kilometers is default; point is decimal separator; if units, put space then unit", "{0.key}");
     321  throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "kilometers");
    310322  assertMatch: "way distance=something";
    311323  assertMatch: "way distance=-5";
Note: See TracChangeset for help on using the changeset viewer.