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 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.
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.
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.
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.