6#include "validatorregularexpression_p.h"
14 :
ValidatorRule(*new ValidatorRegularExpressionPrivate(field, regex, messages, defValKey))
31 if (d->regex.isValid()) {
38 "ValidatorRegularExpression: Validation failed for field %s at %s::%s "
39 "because value does not match the following regular expression: %s",
41 qPrintable(c->controllerName()),
42 qPrintable(c->actionName()),
43 qPrintable(d->regex.pattern()));
50 qCWarning(C_VALIDATOR,
51 "ValidatorRegularExpression: the regular expression for the field %s at %s::%s "
54 qPrintable(c->controllerName()),
55 qPrintable(c->actionName()),
56 qPrintable(d->regex.errorString()));
69 error = c->
translate(
"Cutelyst::ValidatorRegularExpression",
70 "Does not match the desired format.");
73 error = c->
translate(
"Cutelyst::ValidatorRegularExpression",
74 "The “%1” field does not match the desired format.")
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
<Cutelyst/Plugins/Utils/validatorregularexpression.h>
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
Performs the validation and returns the result.
~ValidatorRegularExpression() override
Deconstructs the regex validator.
ValidatorRegularExpression(const QString &field, const QRegularExpression ®ex, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Constructs a new regex validator.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Returns a generic error message if validation failed.
Base class for all validator rules.
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.
void defaultValue(Context *c, ValidatorReturnType *result, const char *validatorName) const
I a defValKey has been set in the constructor, this will try to get the default value from the stash ...
QString value(const ParamsMultiMap ¶ms) const
Returns the value of the field from the input params.
QString validationDataError(Context *c, const QVariant &errorData=QVariant()) const
Returns an error message if any validation data is missing or invalid.
QString validationError(Context *c, const QVariant &errorData=QVariant()) const
Returns a descriptive error message if validation failed.
The Cutelyst namespace holds all public Cutelyst API.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
void setValue(const T &value)
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.