Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Unified Diff: chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc

Issue 2694693003: [Payments] Add support for required fields in editor validation (Closed)
Patch Set: addressed comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/editor_view_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc b/chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc
index 20439f90528e40483fc91f11fca1bc9ce297b89f..8eb09d303fe88bf79f8c77b0b983ae4f5c37d5db 100644
--- a/chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc
+++ b/chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc
@@ -33,13 +33,13 @@ std::vector<EditorField> CreditCardEditorViewController::GetFieldDefinitions() {
return std::vector<EditorField>{
{autofill::CREDIT_CARD_NAME_FULL,
l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_NAME_ON_CARD),
- EditorField::LengthHint::HINT_LONG},
+ EditorField::LengthHint::HINT_LONG, true},
{autofill::CREDIT_CARD_NUMBER,
l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_CREDIT_CARD_NUMBER),
- EditorField::LengthHint::HINT_LONG},
+ EditorField::LengthHint::HINT_LONG, true},
{autofill::CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR,
l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_EXPIRATION_DATE),
- EditorField::LengthHint::HINT_SHORT}};
+ EditorField::LengthHint::HINT_SHORT, true}};
}
bool CreditCardEditorViewController::ValidateModelAndSave() {
@@ -79,10 +79,15 @@ CreditCardEditorViewController::ValidationDelegate::~ValidationDelegate() {}
bool CreditCardEditorViewController::ValidationDelegate::ValidateTextfield(
views::Textfield* textfield) {
- base::string16 error_message;
- // TODO(mathp): Display |error_message| around |textfield|.
- return autofill::IsValidForType(textfield->text(), field_.type,
- &error_message);
+ if (!textfield->text().empty()) {
+ base::string16 error_message;
+ // TODO(mathp): Display |error_message| around |textfield|.
+ return autofill::IsValidForType(textfield->text(), field_.type,
+ &error_message);
+ }
+
+ // TODO(mathp): Display "required" error if applicable.
+ return !field_.required;
}
} // namespace payments
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/editor_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698