cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
Checks if a field is available and has a specific value. More...
#include <Cutelyst/Plugins/Utils/validatoraccepted.h>
Public Member Functions | |
ValidatorAccepted (const QString &field, const ValidatorMessages &messages=ValidatorMessages()) | |
~ValidatorAccepted () override | |
Public Member Functions inherited from Cutelyst::ValidatorRule | |
ValidatorRule (const QString &field, const ValidatorMessages &messages={}, const QString &defValKey={}, QByteArrayView validatorName=nullptr) | |
virtual | ~ValidatorRule () |
Deconstructs the ValidatorRule. | |
Static Public Member Functions | |
static bool | validate (const QString &value) |
Returns true if the value is equal to yes , on , 1 , or true . | |
Protected Member Functions | |
QString | genericValidationError (Context *c, const QVariant &errorData=QVariant()) const override |
ValidatorReturnType | validate (Context *c, const ParamsMultiMap ¶ms) const override |
Protected Member Functions inherited from Cutelyst::ValidatorRule | |
ValidatorRule (ValidatorRulePrivate &dd) | |
QString | debugString (Context *c) const |
void | defaultValue (Context *c, ValidatorReturnType *result) const |
QString | field () const noexcept |
virtual QString | genericParsingError (Context *c, const QVariant &errorData={}) const |
virtual QString | genericValidationDataError (Context *c, const QVariant &errorData={}) const |
QString | label (Context *c) const |
QString | parsingError (Context *c, const QVariant &errorData={}) const |
bool | trimBefore () const noexcept |
QString | validationDataError (Context *c, const QVariant &errorData={}) const |
QString | validationError (Context *c, const QVariant &errorData={}) const |
QString | value (const ParamsMultiMap ¶ms) const |
The field under validation must be yes
, on
, 1
, or true
. This is useful for validating "Terms of Service" acceptance. This check will also fail if the input data for the specified field is empty or if the field is not part of the input data.
true
.Definition at line 34 of file validatoraccepted.h.
ValidatorAccepted::ValidatorAccepted | ( | const QString & | field, |
const ValidatorMessages & | messages = ValidatorMessages() |
||
) |
Constructs a new ValidatorAccepted object for the given field using optional custom error messages.
Definition at line 14 of file validatoraccepted.cpp.
|
overridedefault |
Destroys the ValidatorAccepted object.
|
overrideprotectedvirtual |
Returns a generic error message.
Reimplemented from Cutelyst::ValidatorRule.
Definition at line 43 of file validatoraccepted.cpp.
References QString::arg(), QString::isEmpty(), Cutelyst::ValidatorRule::label(), and Cutelyst::Context::qtTrId().
|
overrideprotectedvirtual |
Performs the validation on the input params and returns the result.
If validation succeeds, ValidatorReturnType::value will contain true
.
Implements Cutelyst::ValidatorRule.
Definition at line 22 of file validatoraccepted.cpp.
References Cutelyst::ValidatorRule::debugString(), Cutelyst::ValidatorReturnType::errorMessage, QVariant::setValue(), validate(), Cutelyst::ValidatorRule::validationError(), Cutelyst::ValidatorReturnType::value, and Cutelyst::ValidatorRule::value().