5 #ifndef CUTELYSTVALIDATORRULE_H
6 #define CUTELYSTVALIDATORRULE_H
8 #include <Cutelyst/Plugins/Utils/validator_export.h>
9 #include <Cutelyst/paramsmultimap.h>
11 #include <QLoggingCategory>
12 #include <QScopedPointer>
15 Q_DECLARE_LOGGING_CATEGORY(C_VALIDATOR)
65 explicit operator bool() const noexcept {
return errorMessage.
isNull(); }
70 [[nodiscard]]
bool isValid() const noexcept {
return errorMessage.
isNull(); }
159 const char *customValidationError =
nullptr,
160 const char *customParsingError =
nullptr,
161 const char *customValidationDataError =
nullptr)
163 , validationError(customValidationError)
164 , parsingError(customParsingError)
165 , validationDataError(customValidationDataError)
168 const char *label =
nullptr;
169 const char *validationError =
nullptr;
170 const char *parsingError =
nullptr;
171 const char *validationDataError =
nullptr;
174 class ValidatorRulePrivate;
328 const std::unique_ptr<ValidatorRulePrivate> d_ptr;
385 [[nodiscard]]
QString field() const noexcept;
404 [[nodiscard]]
bool trimBefore() const noexcept;
468 [[nodiscard]]
QString parsingError(Context *c,
const QVariant &errorData = {})
const;
500 virtual QString genericParsingError(Context *c,
const QVariant &errorData = {})
const;
516 [[nodiscard]]
QString validationDataError(Context *c,
const QVariant &errorData = {})
const;
547 virtual QString genericValidationDataError(Context *c,
const QVariant &errorData = {})
const;
553 void defaultValue(Context *c, ValidatorReturnType *result)
const;
561 [[nodiscard]]
QString debugString(Context *c)
const;
564 Q_DECLARE_PRIVATE(ValidatorRule)
565 Q_DISABLE_COPY(ValidatorRule)
571 void setTranslationContext(
const char *trContext) noexcept;
583 void setTrimBefore(
bool trimBefore) noexcept;
585 friend class Validator;
586 friend class ValidatorPrivate;
Base class for all validator rules.
virtual ~ValidatorRule()
Deconstructs the ValidatorRule.
virtual ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const =0
The Cutelyst namespace holds all public Cutelyst API.
bool isNull() const const
Stores custom error messages and the input field label.
ValidatorMessages(const char *customLabel, const char *customValidationError=nullptr, const char *customParsingError=nullptr, const char *customValidationDataError=nullptr)
Constructs a new ValidatorMessages object with the given parameters.
ValidatorMessages()=default
Contains the result of a single input parameter validation.
bool isValid() const noexcept