Opened 3 years ago

Last modified 19 months ago

#22486 closed enhancement

Warn about invalid currency symbol in charge — at Version 1

Reported by: Famlam Owned by: team
Priority: normal Milestone:
Component: Core validator Version: tested
Keywords: charge Cc:

Description (last modified by Famlam)

The wiki of charge defines the format as charge = <amount> <currency code>[/<unit>][/<time unit>]. Currency code is the 3-letter, uppercase code from ISO 4217.

Despite this, there is a significant usage where either the currency is not specified, or the currency is written using the symbol (either before or after the number), as can be seen on TagInfo

Hence, I would propose to add the following rule to the validator rules:

*[charge][charge!=0][charge!~/^[0-9]+(\.[0-9]+)? [A-Z]{3}($|\/|;)/] {
  throwWarning: tr("{0} should be structured as <(decimal) number><space><(uppercase) three letter currency code>[/optional unit][/optional time unit]", "{0.key}");
  assertMatch: "node charge=€12";
  assertMatch: "node charge=\"0.22 $/liter\"";
  assertMatch: "node charge=12.22";
  assertMatch: "node charge=\"12 EURO\"";
  assertMatch: "node charge=\"12 eur\"";
  assertMatch: "node charge=12EUR";
  assertMatch: "node charge=EUR12";
  assertNoMatch: "node charge=0";
  assertNoMatch: "node charge=\"12 EUR\"";
  assertNoMatch: "node charge=\"12 EUR/person; 18 EUR/child\"";
  assertNoMatch: "node charge=\"0.223 USD/liter\"";
  assertNoMatch: "node charge=\"12.223 YEN/1 person/1 hour\"";
}

Change History (1)

comment:1 by Famlam, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.