Re: [w3c/payment-request] Add regionCode attribute (#690)

marcoscaceres commented on this pull request.



> @@ -2138,6 +2139,22 @@ <h2>
                 </li>
               </ol>
             </li>
+            <li>If <var>details</var>["<a>regionCode</a>"] is present and not
+            the empty string:
+              <ol>
+                <li>Let <var>regionCode</var> be the result of <a>strip leading
+                and trailing ASCII whitespace</a> and <a data-cite=
+                "!INFRA#ascii-uppercase">ASCII uppercasing</a>
+                <var>details</var>["<a>regionCode</a>"].
+                </li>
+                <li>If <var>regionCode</var> is not a valid [[!ISO3166-2]]
+                subdivision code, throw a <a>RangeError</a> exception.

ISO3166-2 defines the structure of subdivision codes, and could be usable (section 5.2)... but it's defined in terms that are not "web terms" (e.g., speaks about "characters" instead of code points). 

Options:

  1. Just send implementers to ISO3166-2, and say "valid as per Section 5.2 of ISO3166-2".
  1. Take ISO3166-2 format, and talk about it in terms of infra.
  
With 1, the interop risk is low... the format is pretty simple: 
 *  a country-code, a hyphen, 1-3 aphanum.

For 2, we could do:

The steps to validate a region code are as follows. The algorithm takes a string `regionCode` as input. The algorithm returns true if valid, false if invalid.

  1. If `regionCode` doesn't have exactly one U+002D (-), return false.
  1. Set `subCode` to the result of ASCII uppercase `regionCode`.   
  1. Split `subCode` on hyphen, and let `country` be the first item, and `subdivision` be the second item. 
  1. If `country` is not  ASCII upper alpha and length 2, return false.      
  1. If `country` is not a [[!ISO3166-1]] country code, return false.
  1. If `subdivision` is not ASCII alphanumeric and of length between 1 and 3, return false. 
  1. If  `subdivision` is not [[!ISO3166-2]] subdivision that corresponds to `country`, return false.
  1. Return true.

@domenic, happy to add 2.  

-- 
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/payment-request/pull/690#discussion_r174991636

Received on Friday, 16 March 2018 03:46:33 UTC