|
cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
Checks if the value of the input field contains FQDN according to RFC 1035. More...
#include <Cutelyst/Plugins/Utils/validatordomain.h>

Public Types | |
| enum | Diagnose : quint8 { Valid , MissingDNS , InvalidChars , LabelTooLong , TooLong , InvalidLabelCount , EmptyLabel , InvalidTLD , DashStart , DashEnd , DigitStart , DNSTimeout } |
| Possible diagnose information for the checked domain. More... | |
Public Member Functions | |
| ValidatorDomain (const QString &field, bool checkDNS=false, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString()) | |
| Constructs a new ValidatorDomain with the given parameters. | |
| ~ValidatorDomain () override | |
| Deconstructs ValidatorDomain. | |
| Public Member Functions inherited from Cutelyst::ValidatorRule | |
| ValidatorRule (const QString &field, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString()) | |
| Constructs a new ValidatorRule with the given parameters. | |
| virtual | ~ValidatorRule () |
| Deconstructs the ValidatorRule. | |
Static Public Member Functions | |
| static QString | diagnoseString (Context *c, Diagnose diagnose, const QString &label=QString()) |
| Returns a human readable description of a Diagnose. | |
| static bool | validate (const QString &value, bool checkDNS, Diagnose *diagnose=nullptr, QString *extractedValue=nullptr) |
Returns true if value is a valid domain name. | |
Protected Member Functions | |
| QString | genericValidationError (Context *c, const QVariant &errorData=QVariant()) const override |
| Returns a generic error message if validation failed. | |
| ValidatorReturnType | validate (Context *c, const ParamsMultiMap ¶ms) const override |
| Performs the validation and returns the result. | |
| Protected Member Functions inherited from Cutelyst::ValidatorRule | |
| ValidatorRule (ValidatorRulePrivate &dd) | |
| Constructs a new ValidatorRule object with the given private class. | |
| 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 and put it into the result. | |
| QString | field () const |
| Returns the name of the field to validate. | |
| virtual QString | genericParsingError (Context *c, const QVariant &errorData=QVariant()) const |
| Returns a generic error message if an error occures while parsing input. | |
| virtual QString | genericValidationDataError (Context *c, const QVariant &errorData=QVariant()) const |
| Returns a generic error message if any validation data is missing or invalid. | |
| QString | label (Context *c) const |
| Returns the human readable field label used for generic error messages. | |
| QString | parsingError (Context *c, const QVariant &errorData=QVariant()) const |
| Returns an error message if an error occurred while parsing input. | |
| bool | trimBefore () const |
| Returns true if the field value should be trimmed before validation. | |
| 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. | |
| QString | value (const ParamsMultiMap ¶ms) const |
| Returns the value of the field from the input params. | |
The field under validation must contain a fully qualified domain name according to RFC 1035. If checkDNS is set to false, there will be no check if the domain is known to the domain name system, the validator will only check conformance to RFC 1035. Internationalized domain names will first be converted into puny code according to IDNA.
Definition at line 37 of file validatordomain.h.
| enum Cutelyst::ValidatorDomain::Diagnose : quint8 |
Definition at line 44 of file validatordomain.h.
| ValidatorDomain::ValidatorDomain | ( | const QString & | field, |
| bool | checkDNS = false, | ||
| const ValidatorMessages & | messages = ValidatorMessages(), | ||
| const QString & | defValKey = QString() ) |
| field | Name of the input field to validate. |
| checkDNS | If true, a DNS lookup will be performed to check if the domain name exists in the domain name system. |
| messages | Custom error messages if validation fails. |
| defValKey | Stash key containing a default value if input field is empty. This value will NOT be validated. |
Definition at line 16 of file validatordomain.cpp.
References Cutelyst::ValidatorRule::ValidatorRule(), and Cutelyst::ValidatorRule::field().
Referenced by validate().
|
override |
Definition at line 24 of file validatordomain.cpp.
|
static |
| c | Current Context, used for translations. |
| diagnose | The Diagnose to get the description for. |
| label | Optinonal label that will be part of the diagnose string if not empty. |
Definition at line 212 of file validatordomain.cpp.
References QString::arg(), DashEnd, DashStart, DigitStart, DNSTimeout, EmptyLabel, InvalidChars, InvalidLabelCount, InvalidTLD, Cutelyst::ValidatorRule::label(), LabelTooLong, MissingDNS, TooLong, Cutelyst::Context::translate(), and Valid.
Referenced by genericValidationError().
|
overrideprotectedvirtual |
errorData will contain the Diagnose returned by ValidatorDomain::validate().
Reimplemented from Cutelyst::ValidatorRule.
Definition at line 388 of file validatordomain.cpp.
References diagnoseString(), Cutelyst::ValidatorRule::label(), and QVariant::value().
|
overrideprotectedvirtual |
If validation succeeded, ValidatorReturnType::value will contain the input paramter value as ACE version of the domain in a QString.
Implements Cutelyst::ValidatorRule.
Definition at line 366 of file validatordomain.cpp.
References ValidatorDomain(), Cutelyst::ValidatorRule::defaultValue(), Cutelyst::ValidatorReturnType::errorMessage, QString::isEmpty(), QVariant::setValue(), validate(), Cutelyst::ValidatorRule::validationError(), Cutelyst::ValidatorReturnType::value, and Cutelyst::ValidatorRule::value().