Chromium Code Reviews| 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" | |
|
please use gerrit instead
2016/04/12 20:42:31
Let's not alter includes in this patch. This patch
| |
| 9 | 8 |
| 10 namespace blink { | 9 namespace blink { |
| 11 | 10 |
| 12 bool PaymentsValidators::isValidCurrencyCodeFormat(const String& code, String* o ptionalErrorMessage) | 11 bool PaymentsValidators::isValidCurrencyCodeFormat(const String& code, String* o ptionalErrorMessage) |
| 13 { | 12 { |
| 14 if (ScriptRegexp("^[A-Z]{3}$", TextCaseSensitive).match(code) == 0) | 13 if (ScriptRegexp("^[A-Z]{3}$", TextCaseSensitive).match(code) == 0) |
| 15 return true; | 14 return true; |
| 16 | 15 |
| 17 if (optionalErrorMessage) | 16 if (optionalErrorMessage) |
| 18 *optionalErrorMessage = "'" + code + "' is not a valid ISO 4217 currency code, should be 3 upper case letters [A-Z]"; | 17 *optionalErrorMessage = "'" + code + "' is not a valid ISO 4217 currency code, should be 3 upper case letters [A-Z]"; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 51 |
| 53 return false; | 52 return false; |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool PaymentsValidators::isValidScriptCodeFormat(const String& code, String* opt ionalErrorMessage) | 55 bool PaymentsValidators::isValidScriptCodeFormat(const String& code, String* opt ionalErrorMessage) |
| 57 { | 56 { |
| 58 if (ScriptRegexp("^([A-Z][a-z]{3})?$", TextCaseSensitive).match(code) == 0) | 57 if (ScriptRegexp("^([A-Z][a-z]{3})?$", TextCaseSensitive).match(code) == 0) |
| 59 return true; | 58 return true; |
| 60 | 59 |
| 61 if (optionalErrorMessage) | 60 if (optionalErrorMessage) |
| 62 *optionalErrorMessage = "'" + code + "' is not a valid ISO 1524 script c ode, should be an upper case letter [A-Z] followed by 3 lower case letters [a-z] "; | 61 *optionalErrorMessage = "'" + code + "' is not a valid ISO 15924 script code, should be an upper case letter [A-Z] followed by 3 lower case letters [a-z ]"; |
| 63 | 62 |
| 64 return false; | 63 return false; |
| 65 } | 64 } |
| 66 | 65 |
| 67 } // namespace blink | 66 } // namespace blink |
| OLD | NEW |