6#include "validatorurl_p.h"
13 Constraints constraints,
17 :
ValidatorRule(*new ValidatorUrlPrivate(field, constraints, schemes, messages, defValKey))
36 if (!url.isValid() || url.isEmpty()) {
55 ?
QStringList({QStringLiteral(
"http"), QStringLiteral(
"https")})
58 if (!schemeList.
empty()) {
60 bool foundScheme =
false;
61 for (
const QString &s : schemeList) {
63 if (url.scheme() == sl) {
75 qCDebug(C_VALIDATOR).noquote() <<
debugString(c) <<
"Not a valid URL";
97 return c->
qtTrId(
"cutelyst-valurl-genvalerr");
101 return c->
qtTrId(
"cutelyst-valurl-genvalerr-label").
arg(_label);
QString qtTrId(const char *id, int n=-1) const
Base class for all validator rules.
QString validationError(Context *c, const QVariant &errorData={}) const
QString label(const Context *c) const
QString debugString(const Context *c) const
std::function< void(ValidatorReturnType &&result)> ValidatorRtFn
Void callback function for validator rules that processes the ValidatorReturnType.
void defaultValue(Context *c, ValidatorReturnType *result) const
QString value(const ParamsMultiMap ¶ms) const
The field under validation must be a valid URL.
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
ValidatorUrl(const QString &field, Constraints constraints=NoConstraint, const QStringList &schemes={}, const ValidatorMessages &messages={}, const QString &defValKey={})
The Cutelyst namespace holds all public Cutelyst API.
QString arg(Args &&... args) const const
bool isEmpty() const const
QString toLower() const const
void setValue(QVariant &&value)
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.