QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
IxValidator.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifndef _IX_VALIDATOR_H_
33#define _IX_VALIDATOR_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
47
48namespace qx {
49
50class IxDataMember;
51class QxInvalidValueX;
52
61{
62
63public:
64
66 {
67 not_null, not_empty, min_value, max_value,
68 min_length, max_length, date_past, date_future,
69 min_decimal, max_decimal, regular_expression, e_mail,
70 recursive_validator, custom_validator
71 };
72
73protected:
74
76 QString m_message;
77 QString m_group;
78 QVariantList m_Constraints;
80
81public:
82
84 virtual ~IxValidator();
85
87 QString getMessage() const;
88 QString getGroup() const;
89 QVariant getConstraint() const;
90 QVariantList getConstraints() const;
92
93 void setMessage(const QString & s);
94 void setGroup(const QString & s);
95 void setConstraint(const QVariant & v);
96 void setConstraints(const QVariantList & lst);
98
99 virtual void validate(void * pOwner, QxInvalidValueX & lstInvalidValues) const;
100
101protected:
102
104
105 void validateNotNull(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
106 void validateNotEmpty(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
107 void validateMinValue(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
108 void validateMaxValue(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
109 void validateMinDecimal(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
110 void validateMaxDecimal(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
111 void validateMinLength(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
112 void validateMaxLength(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
113 void validateDatePast(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
114 void validateDateFuture(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
115 void validateRegularExpression(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
116 void validateEMail(const QVariant & v, QxInvalidValueX & lstInvalidValues) const;
117
118};
119
120typedef std::shared_ptr<IxValidator> IxValidator_ptr;
121
122} // namespace qx
123
124#endif // _IX_VALIDATOR_H_
#define QX_DLL_EXPORT
Definition QxMacro.h:182
Used by introspection engine (IxClass, IxDataMember, IxFunction, etc.) to add meta-data (property bag...
qx::IxDataMember : common interface for all class properties registered into QxOrm context
qx::IxValidator : common interface for validator engine
Definition IxValidator.h:61
void validateEMail(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
virtual ~IxValidator()
QVariantList getConstraints() const
void validateNotEmpty(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
void setGroup(const QString &s)
void validateMaxDecimal(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
IxDataMember * m_pDataMember
Registered property associated to validator.
Definition IxValidator.h:79
QString getMessage() const
void validateMinLength(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
QString m_group
Validator group.
Definition IxValidator.h:77
void validateMinDecimal(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
validator_type m_type
Validator type.
Definition IxValidator.h:75
void validateDateFuture(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
void validateMinValue(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
void setConstraint(const QVariant &v)
void initDefaultMessage()
void setDataMember(IxDataMember *p)
QString getGroup() const
virtual void validate(void *pOwner, QxInvalidValueX &lstInvalidValues) const
void validateDatePast(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
void validateRegularExpression(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
QVariantList m_Constraints
List of constraints to verify.
Definition IxValidator.h:78
void validateMaxLength(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
QVariant getConstraint() const
validator_type getType() const
void validateMaxValue(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
IxDataMember * getDataMember() const
void validateNotNull(const QVariant &v, QxInvalidValueX &lstInvalidValues) const
void setMessage(const QString &s)
QString m_message
Validator message when invalid value is detected.
Definition IxValidator.h:76
void setConstraints(const QVariantList &lst)
IxValidator(validator_type type)
qx::QxInvalidValueX : list of invalid values
qx::QxPropertyBag : used by introspection engine (IxClass, IxDataMember, IxFunction,...
Root namespace for all QxOrm library features.
std::shared_ptr< IxValidator > IxValidator_ptr