forked from giowck/symphytum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformwidgetvalidator.h
executable file
·62 lines (47 loc) · 2.05 KB
/
formwidgetvalidator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* \class FormWidgetValidator
* \brief This utility is used to validate input data of form widgets and delegates.
* Each form widget has its own metadata edit properties which
* delineate valid data from invalid one. This utility is designed
* to do input validation in one central module, in order to avoid
* code duplication, for example FormView and TableView uses this.
* \author Giorgio Wicklein - GIOWISYS Software
* \date 04/07/2012
*/
#ifndef FORMWIDGETVALIDATOR_H
#define FORMWIDGETVALIDATOR_H
//-----------------------------------------------------------------------------
// Headers
//-----------------------------------------------------------------------------
#include "../components/metadataengine.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class MetadataPropertiesParser;
class QString;
class QVariant;
//-----------------------------------------------------------------------------
// FormWidgetValidator
//-----------------------------------------------------------------------------
class FormWidgetValidator
{
public:
/** Construct a validator with the specified metadata edit properties */
FormWidgetValidator(const QString &metadataEditProperties,
MetadataEngine::FieldType type);
~FormWidgetValidator();
/**
* Validate data
* @param inputData - the data to validate
* @param errorMessage - a reference where to save error message
* if data is not valid (ie. why not valid)
* @return bool - whether the data is valid or not
*/
bool validate(const QVariant &inputData, QString &errorMessage);
private:
bool validateTextType(const QVariant &inputData, QString &errorMessage);
bool validateNumericType(const QVariant &inputData, QString &errorMessage);
MetadataPropertiesParser *m_parser;
MetadataEngine::FieldType m_fieldType;
};
#endif // FORMWIDGETVALIDATOR_H