6 #include "validatoraccepted_p.h" 14 :
ValidatorRule(*new ValidatorAcceptedPrivate(field, messages))
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 validationError(Context *c, const QVariant &errorData=QVariant()) const
Returns a descriptive error message if validation failed.
Stores custom error messages and the input field label.
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
~ValidatorAccepted() override
Deconstructs the accepted validator.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Creates a generic error message.
bool isEmpty() const const
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
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.
static bool validate(const QString &value)
Returns true if the value is yes, on, 1, or true.
void setValue(const T &value)
QString value(const ParamsMultiMap ¶ms) const
Returns the value of the field from the input params.
ValidatorAccepted(const QString &field, const ValidatorMessages &messages=ValidatorMessages())
Constructs a new accepted validator.
QString field() const
Returns the name of the field to validate.
Contains the result of a single input parameter validation.