validation.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
6#define COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
7
8#include "base/strings/string16.h"
9
10namespace base {
11class Time;
12}  // namespace base;
13
14namespace autofill {
15
16// Returns true if |year| and |month| describe a date later than |now|.
17// |year| must have 4 digits.
18bool IsValidCreditCardExpirationDate(const base::string16& year,
19                                     const base::string16& month,
20                                     const base::Time& now);
21bool IsValidCreditCardExpirationDate(int year,
22                                     int month,
23                                     const base::Time& now);
24
25// Returns true if |text| looks like a valid credit card number.
26// Uses the Luhn formula to validate the number.
27bool IsValidCreditCardNumber(const base::string16& text);
28
29// Returns true if |text| looks like a valid credit card security code.
30bool IsValidCreditCardSecurityCode(const base::string16& text);
31
32// Returns true if |code| looks like a valid credit card security code
33// for the type of credit card designated by |number|.
34bool IsValidCreditCardSecurityCode(const base::string16& code,
35                                   const base::string16& number);
36
37// Returns true if |text| looks like a valid e-mail address.
38bool IsValidEmailAddress(const base::string16& text);
39
40// Returns true if |text| is a valid US state name or abbreviation.  It is
41// case insensitive.  Valid for US states only.
42bool IsValidState(const base::string16& text);
43
44// Returns true if |text| looks like a valid zip code.
45// Valid for US zip codes only.
46bool IsValidZip(const base::string16& text);
47
48// Returns true if |text| looks like an SSN, with or without separators.
49bool IsSSN(const string16& text);
50
51}  // namespace autofill
52
53#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_VALIDATION_H_
54