Modify

Opened 5 months ago

Last modified 5 months ago

#22486 new enhancement

Warn about invalid currency symbol in charge

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\"";
}

Attachments (0)

Change History (1)

comment:1 Changed 5 months ago by Famlam

Description: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set.
to The owner will be changed from team to the specified user.
The owner will change to Famlam
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.