cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatorpwquality.h
1/*
2 * SPDX-FileCopyrightText: (C) 2018-2022 Matthias Fehring <mf@huessenbergnetz.de>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef CUTELYSTVALIDATORPWQUALITY_H
6#define CUTELYSTVALIDATORPWQUALITY_H
7
8#include "validatorrule.h"
9
10#include <Cutelyst/cutelyst_global.h>
11
12namespace Cutelyst {
13
14class ValidatorPwQualityPrivate;
15
56class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorPwQuality : public ValidatorRule
57{
58public:
70 explicit ValidatorPwQuality(const QString &field,
71 int threshold = 30,
72 const QVariant &options = QVariant(),
73 const QString &userName = QString(),
74 const QString &oldPassword = QString(),
75 const ValidatorMessages &messages = ValidatorMessages());
76
80 ~ValidatorPwQuality() override;
81
93 static int validate(const QString &value,
94 const QVariant &options = QVariant(),
95 const QString &oldPassword = QString(),
96 const QString &user = QString());
97
108 static QString errorString(Context *c,
109 int returnValue,
110 const QString &label = QString(),
111 int threshold = 0);
112
113protected:
120 ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
121
127 QString genericValidationError(Context *c, const QVariant &errorData) const override;
128
129private:
130 Q_DECLARE_PRIVATE(ValidatorPwQuality)
131 Q_DISABLE_COPY(ValidatorPwQuality)
132};
133
134} // namespace Cutelyst
135
136#endif // CUTELYSTVALIDATORPWQUALITY_H
The Cutelyst Context.
Definition context.h:39
ValidatorPwQuality(const QString &field, int threshold=30, const QVariant &options=QVariant(), const QString &userName=QString(), const QString &oldPassword=QString(), const ValidatorMessages &messages=ValidatorMessages())
Constructs a new ValidatorPwQuality with the given parameters.
static QString errorString(Context *c, int returnValue, const QString &label=QString(), int threshold=0)
Returns a human readable string for the return value of ValidatorPwQuality::validate().
QString genericValidationError(Context *c, const QVariant &errorData) const override
Returns a generic error message if validation failed.
QString label(Context *c) const
Returns the human readable field label used for generic error messages.
QString field() const
Returns the name of the field to validate.
ValidatorRule(const QString &field, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Constructs a new ValidatorRule with the given parameters.
QString value(const ParamsMultiMap &params) const
Returns the value of the field from the input params.
static int validate(const QString &value, const QVariant &options=QVariant(), const QString &oldPassword=QString(), const QString &user=QString())
Returns the password quality score for value.
The Cutelyst namespace holds all public Cutelyst API.
Definition Mainpage.dox:8
QMultiMap< QString, QString > ParamsMultiMap
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.