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 validationError(Context *c, const QVariant &errorData=QVariant()) const
Returns a descriptive error message if validation failed.
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
Performs the validation and returns the result.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Returns a generic error message if validation failed.
Stores custom error messages and the input field label.
ValidatorRegularExpression(const QString &field, const QRegularExpression ®ex, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Constructs a new regex validator.
bool isEmpty() const const
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
QString validationDataError(Context *c, const QVariant &errorData=QVariant()) const
Returns an error message if any validation data is missing or invalid.
The Cutelyst namespace holds all public Cutelyst API.
Base class for all validator rules.
QString label(Context *c) const
Returns the human readable field label used for generic error messages.
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString value(const ParamsMultiMap ¶ms) const
Returns the value of the field from the input params.
QString field() const
Returns the name of the field to validate.
Contains the result of a single input parameter validation.
QString arg(Args &&... args) const const
~ValidatorRegularExpression() override
Deconstructs the regex validator.
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 ...
<Cutelyst/Plugins/Utils/validatorregularexpression.h>
void setValue(QVariant &&value)