From 7b497f991d788c991457f1167d472a77f2789cdc Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 19 Jun 2024 01:33:30 +0200 Subject: [PATCH] Fix: units which used a 'string'-validator might not detect the actual denomination. They have now been forbidden and fixed --- assets/layers/charging_station/charging_station.json | 5 +++-- assets/layers/charging_station/charging_station.proto.json | 5 +++-- assets/layers/entrance/entrance.json | 3 ++- src/Models/Unit.ts | 4 ++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/assets/layers/charging_station/charging_station.json b/assets/layers/charging_station/charging_station.json index d65d13e90..354d98d27 100644 --- a/assets/layers/charging_station/charging_station.json +++ b/assets/layers/charging_station/charging_station.json @@ -2403,7 +2403,8 @@ "de": "Wie lange darf man hier maximal parken?" }, "freeform": { - "key": "maxstay" + "key": "maxstay", + "type": "pfloat" }, "render": { "en": "One can stay at most {canonical(maxstay)}", @@ -3329,4 +3330,4 @@ }, "neededChangesets": 10 } -} \ No newline at end of file +} diff --git a/assets/layers/charging_station/charging_station.proto.json b/assets/layers/charging_station/charging_station.proto.json index 4bbdde3f3..12cbcadf3 100644 --- a/assets/layers/charging_station/charging_station.proto.json +++ b/assets/layers/charging_station/charging_station.proto.json @@ -564,7 +564,8 @@ "nl": "Hoelang mag een voertuig hier blijven staan?" }, "freeform": { - "key": "maxstay" + "key": "maxstay", + "type": "pfloat" }, "render": { "en": "One can stay at most {canonical(maxstay)}", @@ -1049,4 +1050,4 @@ }, "neededChangesets": 10 } -} \ No newline at end of file +} diff --git a/assets/layers/entrance/entrance.json b/assets/layers/entrance/entrance.json index 91bf1d8bc..b26e76932 100644 --- a/assets/layers/entrance/entrance.json +++ b/assets/layers/entrance/entrance.json @@ -515,7 +515,8 @@ "cs": "Jaká je šířka těchto dveří/vchodu?" }, "freeform": { - "key": "width" + "key": "width", + "type": "pfloat" } }, { diff --git a/src/Models/Unit.ts b/src/Models/Unit.ts index 00ac6806d..f1666b57e 100644 --- a/src/Models/Unit.ts +++ b/src/Models/Unit.ts @@ -27,6 +27,10 @@ export class Unit { ) { this.quantity = quantity this._validator = validator + if(!inverted && ["string","text","key","icon","translation","fediverse","id"].indexOf(validator.name) >= 0){ + console.trace("Unit error") + throw "Invalid unit configuration. The validator is of a forbidden type: "+validator.name+"; set a (number) type to your freeform key or set inverted. Hint: this unit is applied onto keys: "+appliesToKeys.join("; ") + } this.inverted = inverted this.appliesToKeys = new Set(appliesToKeys) this.denominations = applicableDenominations