6#include "validatoraccepted_p.h"
12const QStringList ValidatorAcceptedPrivate::trueVals{u
"yes"_qs, u
"on"_qs, u
"1"_qs, u
"true"_qs};
16 :
ValidatorRule(*new ValidatorAcceptedPrivate(field, messages))
28 result.
value.setValue<
bool>(
true);
31 result.
value.setValue<
bool>(
false);
40 return ValidatorAcceptedPrivate::trueVals.contains(
value, Qt::CaseInsensitive);
44 const QVariant &errorData)
const
48 const QString _label =
label(c);
49 if (_label.isEmpty()) {
50 error = c->
translate(
"Cutelyst::ValidatorAccepted",
"Has to be accepted.");
53 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 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.
QString debugString(Context *c) const
Returns a string that can be used for debug output if validation fails.
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
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.