![]() |
cutelyst 5.0.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={}) | |
~ValidatorAccepted () override | |
![]() | |
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 |
void | validateCb (Context *c, const ParamsMultiMap ¶ms, ValidatorRtFn cb) const override |
![]() | |
ValidatorRule (ValidatorRulePrivate &dd) | |
QString | debugString (const Context *c) const |
void | defaultValue (Context *c, ValidatorReturnType *result) const |
void | defaultValue (Context *c, ValidatorRtFn cb) 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 (const 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 |
Additional Inherited Members | |
![]() | |
using | ValidatorRtFn = std::function< void(ValidatorReturnType &&result)> |
Void callback function for validator rules that processes the ValidatorReturnType. | |
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 32 of file validatoraccepted.h.
|
explicit |
Constructs a new ValidatorAccepted object for the given field using optional custom error messages.
Definition at line 15 of file validatoraccepted.cpp.
|
overridedefault |
Destroys the ValidatorAccepted object.
|
overrideprotectedvirtual |
Returns a generic error message.
Reimplemented from Cutelyst::ValidatorRule.
Definition at line 54 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
, otherwise false
.
Implements Cutelyst::ValidatorRule.
Definition at line 23 of file validatoraccepted.cpp.
References Cutelyst::ValidatorRule::debugString(), Cutelyst::ValidatorReturnType::errorMessage, QVariant::setValue(), validate(), Cutelyst::ValidatorRule::validationError(), Cutelyst::ValidatorReturnType::value, and Cutelyst::ValidatorRule::value().
|
overrideprotectedvirtual |
Performs the validation on the input params and calls the cb with the ValidatorReturnType as argument.
If validation succeeds, ValidatorReturnType::value will contain true
, otherwise false
.
Reimplemented from Cutelyst::ValidatorRule.
Definition at line 39 of file validatoraccepted.cpp.
References Cutelyst::ValidatorRule::debugString(), validate(), Cutelyst::ValidatorRule::validationError(), and Cutelyst::ValidatorRule::value().