OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/payments/PaymentsValidators.h" | 5 #include "modules/payments/PaymentsValidators.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptRegexp.h" | 7 #include "bindings/core/v8/ScriptRegexp.h" |
8 #include "wtf/text/StringImpl.h" | 8 #include "wtf/text/StringImpl.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 return false; | 34 return false; |
35 } | 35 } |
36 | 36 |
37 bool PaymentsValidators::isValidCountryCodeFormat(const String& code, String* op
tionalErrorMessage) | 37 bool PaymentsValidators::isValidCountryCodeFormat(const String& code, String* op
tionalErrorMessage) |
38 { | 38 { |
39 if (ScriptRegexp("^[A-Z]{2}$", TextCaseSensitive).match(code) == 0) | 39 if (ScriptRegexp("^[A-Z]{2}$", TextCaseSensitive).match(code) == 0) |
40 return true; | 40 return true; |
41 | 41 |
42 if (optionalErrorMessage) | 42 if (optionalErrorMessage) |
43 *optionalErrorMessage = "'" + code + "' is not a valid ISO 3166 country
code, should be 2 upper case letters [A-Z]"; | 43 *optionalErrorMessage = "'" + code + "' is not a valid CLDR country code
, should be 2 upper case letters [A-Z]"; |
44 | 44 |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 bool PaymentsValidators::isValidLanguageCodeFormat(const String& code, String* o
ptionalErrorMessage) | 48 bool PaymentsValidators::isValidLanguageCodeFormat(const String& code, String* o
ptionalErrorMessage) |
49 { | 49 { |
50 if (ScriptRegexp("^([a-z]{2,3})?$", TextCaseSensitive).match(code) == 0) | 50 if (ScriptRegexp("^([a-z]{2,3})?$", TextCaseSensitive).match(code) == 0) |
51 return true; | 51 return true; |
52 | 52 |
53 if (optionalErrorMessage) | 53 if (optionalErrorMessage) |
54 *optionalErrorMessage = "'" + code + "' is not a valid ISO 639 language
code, should be 2-3 lower case letters [a-z]"; | 54 *optionalErrorMessage = "'" + code + "' is not a valid BCP-47 language c
ode, should be 2-3 lower case letters [a-z]"; |
55 | 55 |
56 return false; | 56 return false; |
57 } | 57 } |
58 | 58 |
59 bool PaymentsValidators::isValidScriptCodeFormat(const String& code, String* opt
ionalErrorMessage) | 59 bool PaymentsValidators::isValidScriptCodeFormat(const String& code, String* opt
ionalErrorMessage) |
60 { | 60 { |
61 if (ScriptRegexp("^([A-Z][a-z]{3})?$", TextCaseSensitive).match(code) == 0) | 61 if (ScriptRegexp("^([A-Z][a-z]{3})?$", TextCaseSensitive).match(code) == 0) |
62 return true; | 62 return true; |
63 | 63 |
64 if (optionalErrorMessage) | 64 if (optionalErrorMessage) |
(...skipping 17 matching lines...) Expand all Loading... |
82 if (optionalErrorMessage) | 82 if (optionalErrorMessage) |
83 *optionalErrorMessage = "If language code is empty, then script code
should also be empty"; | 83 *optionalErrorMessage = "If language code is empty, then script code
should also be empty"; |
84 | 84 |
85 return false; | 85 return false; |
86 } | 86 } |
87 | 87 |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 } // namespace blink | 91 } // namespace blink |
OLD | NEW |