cutelyst
4.5.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
Classes providing rules to validate input data. More...
Classes | |
class | Cutelyst::ValidatorAccepted |
Checks if a field is available and has a specific value. More... | |
class | Cutelyst::ValidatorAfter |
Checks if a date, time or datetime is after a comparison value. More... | |
class | Cutelyst::ValidatorAlpha |
Validates an input field for only alphabetic content. More... | |
class | Cutelyst::ValidatorAlphaDash |
Checks a value for only alpha-numeric content and dashes and underscores. More... | |
class | Cutelyst::ValidatorAlphaNum |
Checks a value for only alpha-numeric content. More... | |
class | Cutelyst::ValidatorBefore |
Checks if a date, time or datetime is before a comparison value. More... | |
class | Cutelyst::ValidatorBetween |
Checks if a value or text length is between a minimum and maximum value. More... | |
class | Cutelyst::ValidatorBoolean |
Checks if a value can be casted into a boolean. More... | |
class | Cutelyst::ValidatorCharNotAllowed |
Validates an input field for not allowed characters. More... | |
class | Cutelyst::ValidatorConfirmed |
Checks for a confirmation input field. More... | |
class | Cutelyst::ValidatorDate |
Checks if the input data is a valid date. More... | |
class | Cutelyst::ValidatorDateTime |
Checks if the input data is a valid datetime. More... | |
class | Cutelyst::ValidatorDifferent |
Checks if two values are different. More... | |
class | Cutelyst::ValidatorDigits |
Checks for digits only with optional length check. More... | |
class | Cutelyst::ValidatorDigitsBetween |
Checks for digits only with a length between min and max. More... | |
class | Cutelyst::ValidatorDomain |
Checks if the value of the input field contains a FQDN according to RFC 1035. More... | |
class | Cutelyst::ValidatorEmail |
Checks if the value is a valid email address according to specific RFCs. More... | |
class | Cutelyst::ValidatorFileSize |
Checks if the input field contains a valid file size string like 1.5 GB. More... | |
class | Cutelyst::ValidatorFilled |
The field under validation must not be empty when it is present. More... | |
class | Cutelyst::ValidatorIn |
Checks if the field value is one from a list of values. More... | |
class | Cutelyst::ValidatorInteger |
Checks if the value is an integer. More... | |
class | Cutelyst::ValidatorIp |
Checks if the field value is a valid IP address. More... | |
class | Cutelyst::ValidatorJson |
Checks if the inut data is valid JSON. More... | |
class | Cutelyst::ValidatorMax |
Checks if a value is not bigger or longer than a maximum value. More... | |
class | Cutelyst::ValidatorMin |
Checks if a value is not smaller or shorter than a maximum value. More... | |
class | Cutelyst::ValidatorNotIn |
Checks if the field value is not one from a list of values. More... | |
class | Cutelyst::ValidatorNumeric |
Checks if the field under validation could be casted into a numeric value. More... | |
class | Cutelyst::ValidatorPresent |
The field under validation must be present in input data but can be empty. More... | |
class | Cutelyst::ValidatorPwQuality |
Validates an input field with libpwquality to check password quality. More... | |
class | Cutelyst::ValidatorRegularExpression |
The field under validation must match the given regular expression. More... | |
class | Cutelyst::ValidatorRequired |
Checks if a field is available and not empty. More... | |
class | Cutelyst::ValidatorRequiredIf |
The field under validation must be present and not empty if the other field is equal to any value in a list. More... | |
class | Cutelyst::ValidatorRequiredIfStash |
The field under validation must be present and not empty if the content of a stash key is equal to one from a list. More... | |
class | Cutelyst::ValidatorRequiredUnless |
The field under validation must be present and not empty unless the other field is equal to any value in the list. More... | |
class | Cutelyst::ValidatorRequiredUnlessStash |
The field under validation must be present and not empty unless the content of a stash key is equal to a value in a list. More... | |
class | Cutelyst::ValidatorRequiredWith |
The field under validation must be present and not empty only if any of the other specified fields is present. More... | |
class | Cutelyst::ValidatorRequiredWithAll |
The field under validation must be present and not empty only if all of the other specified fields are present. More... | |
class | Cutelyst::ValidatorRequiredWithout |
The field under validation must be present and not empty only if any of the other specified fields is not present. More... | |
class | Cutelyst::ValidatorRequiredWithoutAll |
The field under validation must be present and not empty only when all of the other specified fields are not present. More... | |
class | Cutelyst::ValidatorSame |
The given field must match the field under validation. More... | |
class | Cutelyst::ValidatorSize |
The field under validation must have a size matching the given value. More... | |
class | Cutelyst::ValidatorTime |
Checks if the input data is a valid time. More... | |
class | Cutelyst::ValidatorUrl |
The field under validation must be a valid URL. More... | |
Functions | |
static bool | Cutelyst::ValidatorEmail::validate (const QString &email, Category threshold=RFC5321, Options options=NoOption, QList< Diagnose > *diagnoses=nullptr) |
Returns true if email is a valid address according to the Category given in the threshold. More... | |
static bool | Cutelyst::ValidatorAccepted::validate (const QString &value) |
Returns true if the value is equal to yes , on , 1 , or true . More... | |
static bool | Cutelyst::ValidatorAlpha::validate (const QString &value, bool asciiOnly=false) |
Returns true if value only contains alphabetic characters. More... | |
static bool | Cutelyst::ValidatorAlphaDash::validate (const QString &value, bool asciiOnly=false) |
Returns true if the value only contains alpha-numeric characters, dashes and underscores. More... | |
static bool | Cutelyst::ValidatorAlphaNum::validate (const QString &value, bool asciiOnly=false) |
Returns true if value only contains alpha-numeric characters. More... | |
static bool | Cutelyst::ValidatorDomain::validate (const QString &value, bool checkDNS, Diagnose *diagnose=nullptr, QString *extractedValue=nullptr) |
Returns true if value is a valid fully qualified domain name. More... | |
static bool | Cutelyst::ValidatorCharNotAllowed::validate (const QString &value, const QString &forbiddenChars, QChar *foundChar=nullptr) |
Returns true if value does not contain any of the forbideden characters. More... | |
static int | Cutelyst::ValidatorPwQuality::validate (const QString &value, const QVariant &options=QVariant(), const QString &oldPassword=QString(), const QString &user=QString()) |
Returns the password quality score for value. More... | |
static bool | Cutelyst::ValidatorIp::validate (const QString &value, Constraints constraints=NoConstraint) |
Returns true if value is a valid IP address within the constraints. More... | |
static bool | Cutelyst::ValidatorFileSize::validate (const QString &value, double min=-1, double max=-1, Option option=NoOption, const QLocale &locale=QLocale(), double *fileSize=nullptr) |
Returns true if value is a valid file size string. More... | |
static bool | Cutelyst::ValidatorDigitsBetween::validate (const QString &value, int min, int max) |
Returns true if value only contains digits and has a length between min and max. More... | |
static bool | Cutelyst::ValidatorDigits::validate (const QString &value, qsizetype length=-1) |
Returns true if value only contains digits. More... | |
All validator rule classes are derived from ValidatorRule and are meant to be used as part of Validator. Read the documentation of Validator to learn more about how to use the Validator and the rules. If you want to write your own validator rule, create a new class that is derived from ValidatorRule and reimplement the validate function.
There are three constructor arguments that are common to almost all validator rules: the name of the field to validate (mandatory), a struct containing translatable ValidatorMessages (optional) and a stash key name that contains a default value if the input field is not available (optional available where it makes sense).
Some validators export their validation logic in a static member function so that it can be used without creating a Validator.
|
static |
[in] | The address to validate. | |
[in] | threshold | The threshold category that limits the diagnose that is accepted as valid. |
[in] | options | Options for the validation process. |
[out] | diagnoses | If not a nullptr , this will contain a list of all issues found by the check, ordered from the highest to the lowest. |
true
if email is a valid address according to the Category given in the threshold. Definition at line 1724 of file validatoremail.cpp.
|
static |
Returns true
if the value is equal to yes
, on
, 1
, or true
, otherwise returns false
.
Definition at line 38 of file validatoraccepted.cpp.
References Qt::CaseInsensitive, and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAccepted::validate().
|
static |
value | The value to validate. |
asciiOnly | If true , only ASCII characters are allowed. |
true
if value only contains alphabetic characters Definition at line 45 of file validatoralpha.cpp.
References QString::contains(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAlpha::validate().
|
static |
value | The value to validate as it is. |
asciiOnly | If true , only ASCII characters are allowed. |
true
if the value only contains alpha-numeric characters, dashes and underscores Definition at line 44 of file validatoralphadash.cpp.
References QString::contains(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAlphaDash::validate().
|
static |
value | The value to validate as it is. |
asciiOnly | If true , only ASCII characters are allowed. |
true
if the value only contains alpha-numeric characters Definition at line 45 of file validatoralphanum.cpp.
References QString::contains(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAlphaNum::validate().
|
static |
value | The value to validate. |
checkDNS | If true , a DNS lookup will be performed to check if the domain name exists in the domain name system. |
diagnose | Optional pointer to a variable that will be filled with the Diagnose that describes the error if validation fails. |
extractedValue | Optional pointer to a variable that will contain the validated domain converted into ACE puny code. |
true
if the value is a valid domain name. Definition at line 26 of file validatordomain.cpp.
References QDnsLookup::A, QDnsLookup::AAAA, QDnsLookup::abort(), QList::at(), QString::at(), QString::chop(), QObject::connect(), Cutelyst::ValidatorDomain::DashEnd, Cutelyst::ValidatorDomain::DashStart, Cutelyst::ValidatorDomain::DigitStart, Cutelyst::ValidatorDomain::DNSTimeout, QList::empty(), Cutelyst::ValidatorDomain::EmptyLabel, QString::endsWith(), QDnsLookup::error, QEventLoop::exec(), QDnsLookup::finished(), QString::fromLatin1(), QDnsLookup::hostAddressRecords(), Cutelyst::ValidatorDomain::InvalidChars, Cutelyst::ValidatorDomain::InvalidLabelCount, Cutelyst::ValidatorDomain::InvalidTLD, QString::isEmpty(), Qt::KeepEmptyParts, Cutelyst::ValidatorDomain::LabelTooLong, QList::last(), QString::length(), QDnsLookup::lookup(), Cutelyst::ValidatorDomain::MissingDNS, QDnsLookup::NoError, QDnsLookup::OperationCancelledError, QEventLoop::quit(), QTimer::singleShot, QList::size(), QString::size(), QString::split(), QString::startsWith(), QUrl::toAce(), QString::toLower(), Cutelyst::ValidatorDomain::TooLong, QChar::unicode(), Cutelyst::ValidatorDomain::Valid, and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorDomain::validate().
|
static |
value | The value to validate. |
forbiddenChars | The list of forbidden characters. |
foundChar | If set, it will contain the first found chararacter that is forbidden. |
true
if the value does not contain any of the forbiddenChars Definition at line 20 of file validatorcharnotallowed.cpp.
References QString::contains(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorCharNotAllowed::validate().
|
static |
value | The value to validate. |
options | <a hrefd=#options">Options for libpwquality. |
oldPassword | Optional old password used for some checks. |
user | Optional user name used for some checks. |
0
is an error, everything >= 0 is a quality score where 0-30 is low, 30-60 medium and 60-100 high quality. For errors you can use ValidatorPwQuality::errorString() to get a human readable string explaining the return value. Definition at line 31 of file validatorpwquality.cpp.
References QByteArray::constData(), QList::data(), QByteArray::isEmpty(), QString::isEmpty(), QVariant::isValid(), QMetaType::QString, QMetaType::QVariantMap, QList::size(), QVariant::toMap(), QVariant::toString(), QString::toUtf8(), QVariant::typeId(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorPwQuality::validate().
|
static |
value | The value to validate. |
constraints | Optional validation constraints. |
true
if value is a valid IP address within the constraints. Definition at line 51 of file validatorip.cpp.
References QString::contains(), Cutelyst::ValidatorIp::IPv4Only, QAbstractSocket::IPv4Protocol, Cutelyst::ValidatorIp::IPv6Only, Cutelyst::ValidatorIp::NoConstraint, Cutelyst::ValidatorIp::NoMultiCast, Cutelyst::ValidatorIp::NoPrivateRange, Cutelyst::ValidatorIp::NoReservedRange, Cutelyst::ValidatorIp::PublicOnly, and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorIp::validate().
|
static |
[in] | value | The value to validate. |
[in] | min | Optional minimum size. Use a number lower 0 to disable the check. |
[in] | max | Optional maximum size. Use a number lower 0 to disable the check. |
[in] | option | Option to use when validating and generating the fileSize. |
[in] | locale | The locale to use when validating the input value. |
[out] | fileSize | Optional pointer to a double variable that will contain the extracted file size if validation succeeded. |
true
if value is a valid file size string. Definition at line 25 of file validatorfilesize.cpp.
References QString::append(), QLocale::decimalPoint(), Cutelyst::ValidatorFileSize::ForceBinary, Cutelyst::ValidatorFileSize::ForceDecimal, QString::isEmpty(), Cutelyst::ValidatorFileSize::OnlyBinary, Cutelyst::ValidatorFileSize::OnlyDecimal, QString::simplified(), QLocale::toDouble(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorFileSize::validate().
|
static |
Nothe that this might return true
for an empty value if 0 is between min and max.
value | The value to validate as it is. |
min | Minimum length of the digits. |
max | Maximum length of the digits. |
true
if value string only contains digits and has a length between min and max, otherwise it returns false. Definition at line 72 of file validatordigitsbetween.cpp.
References QString::length(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorDigitsBetween::validate().
|
static |
Note that this function will return true
for an empty value if the length check is disabled.
value | The value to validate as it is. |
length | Exact length of the digits, defaults to -1 . A value lower 1 disables the length check. |
true
if the value only contains digits Definition at line 59 of file validatordigits.cpp.
References QString::length(), and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorDigits::validate().