Rubber-stamped by Brady Eidson.
[webbrowser.git] / WebCore / html / ValidityState.h
blob7ae95d767d2d71619484cc3884791df979921c2a
1 /*
2 * This file is part of the WebKit project.
4 * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef ValidityState_h
24 #define ValidityState_h
26 #include "HTMLFormControlElement.h"
27 #include <wtf/PassRefPtr.h>
28 #include <wtf/RefCounted.h>
30 namespace WebCore {
32 class ValidityState : public RefCounted<ValidityState> {
33 public:
34 static PassRefPtr<ValidityState> create(HTMLFormControlElement* owner)
36 return adoptRef(new ValidityState(owner));
39 HTMLFormControlElement* control() const { return m_control; }
41 String validationMessage();
42 void setCustomErrorMessage(const String& message) { m_customErrorMessage = message; }
44 bool valueMissing() { return control()->valueMissing(); }
45 bool typeMismatch();
46 bool patternMismatch() { return control()->patternMismatch(); }
47 bool tooLong() { return control()->tooLong(); }
48 bool rangeUnderflow();
49 bool rangeOverflow();
50 bool stepMismatch();
51 bool customError() { return !m_customErrorMessage.isEmpty(); }
52 bool valid();
54 private:
55 ValidityState(HTMLFormControlElement*);
56 HTMLFormControlElement* m_control;
57 String m_customErrorMessage;
59 static bool isValidColorString(const String&);
60 bool isValidEmailAddress(const String&);
63 } // namespace WebCore
65 #endif // ValidityState_h