Re: [w3c/browser-payment-api] Should user agent validate currency? (#490)

We should make it use the infrastructure from the Intl API, IMO:  
 
 * It's basically /^[a-z]{3}$/i (case insensitive match) using [`IsWellFormedCurrencyCode`](http://www.ecma-international.org/ecma-402/2.0/#sec-iswellformedcurrencycode).
 * Throws RangeError when invalid.
 * We don't throw when the currency is unknown (so long as `IsWellFormedCurrencyCode` returns true, it's valid).
 * Canonicalize code internally to uppercase. 

When the value is not in ISO 4217, the canonicalized code can be used as the symbol - we make a note of this in a l18n guidance section. 

Thus:

```JS
// This is fine
const details = {
  total: {
    label: "Total due",
    // FOO50.00
    amount: { currency: "Foo", value: "50.00" }, 
  }
};

// This throws
const details = {
  total: {
    label: "Total due",
    // FOO50.00
    amount: { currency: "this is no good", value: "50.00" }, 
  }
};
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/browser-payment-api/issues/490#issuecomment-291048145

Received on Monday, 3 April 2017 04:50:35 UTC