6#include "validatorin_p.h"
34 vals = d->values.toStringList();
36 vals = c->
stash(d->values.toString()).toStringList();
42 "ValidatorIn: The list of comparison values for the field %s at %s::%s is empty.",
44 qPrintable(c->controllerName()),
45 qPrintable(c->actionName()));
52 "ValidatorIn: Validation failed for field %s at %s::%s: \"%s\" is not part "
53 "of the list of comparison values.",
55 qPrintable(c->controllerName()),
56 qPrintable(c->actionName()),
75 error = c->
translate(
"Cutelyst::ValidatorIn",
"Has to be one of the following values: %1")
82 "The value in the “%1” field has to be one of the following values: %2")
94 error = c->
translate(
"Cutelyst::ValidatorIn",
"The list of comparison values is empty.");
97 error = c->
translate(
"Cutelyst::ValidatorIn",
98 "The list of comparison values for the “%1” field is empty.")
void stash(const QVariantHash &unite)
QLocale locale() const noexcept
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
Performs the validation and returns the result.
~ValidatorIn() override
Deconstructs the in validator.
ValidatorIn(const QString &field, const QVariant &values, Qt::CaseSensitivity cs=Qt::CaseSensitive, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Constructs a new in validator.
QString genericValidationDataError(Context *c, const QVariant &errorData) const override
Returns a generic error messages if the list of comparison values is empty.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Returns a generic error message if validation failed.
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.
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 ...
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 validationDataError(Context *c, const QVariant &errorData=QVariant()) const
Returns an error message if any validation data is missing or invalid.
QString validationError(Context *c, const QVariant &errorData=QVariant()) const
Returns a descriptive error message if validation failed.
The Cutelyst namespace holds all public Cutelyst API.
QMultiMap< QString, QString > ParamsMultiMap
QString createSeparatedList(const QStringList &list) const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isEmpty() const const
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
void setValue(const T &value)
QStringList toStringList() const const
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.