6#include "validatoraccepted_p.h"
33 "ValidatorAccepted: Validation failed for field %s at %s::%s.",
35 qPrintable(c->controllerName()),
36 qPrintable(c->actionName()));
46 {QStringLiteral(
"yes"), QStringLiteral(
"on"), QStringLiteral(
"1"), QStringLiteral(
"true")});
58 error = c->
translate(
"Cutelyst::ValidatorAccepted",
"Has to be accepted.");
61 error = c->
translate(
"Cutelyst::ValidatorAccepted",
"“%1” has to be accepted.");
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
ValidatorAccepted(const QString &field, const ValidatorMessages &messages=ValidatorMessages())
Constructs a new accepted validator.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Creates a generic error message.
~ValidatorAccepted() override
Deconstructs the accepted validator.
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 ¶ms) const
Returns the value of the field from the input params.
QString validationError(Context *c, const QVariant &errorData=QVariant()) const
Returns a descriptive error message if validation failed.
static bool validate(const QString &value)
Returns true if the value is yes, on, 1, or true.
The Cutelyst namespace holds all public Cutelyst API.
QMultiMap< QString, QString > ParamsMultiMap
bool isEmpty() const const
bool contains(const QString &str, Qt::CaseSensitivity cs) 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.