Cutelyst
2.13.0
|
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 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 emptly 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 when any of the other specified fields are 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 yes , on , 1 , or true . 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::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::ValidatorAlpha::validate (const QString &value, bool asciiOnly=false) |
Returns true if value only contains alphabetic 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 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 charachters in forbiddenChars. 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::ValidatorDigits::validate (const QString &value, int length=-1) |
Returns true if value only contains digits. 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... | |
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 almos 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.
|
static |
value | The value to validate. |
true
if the value is yes
, on
, 1
, or true
. Definition at line 50 of file validatoraccepted.cpp.
References Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAccepted::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 57 of file validatoralphanum.cpp.
References Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAlphaNum::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 56 of file validatoralphadash.cpp.
References Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAlphaDash::validate().
|
static |
value | The value to validate. |
asciiOnly | If true , only ASCII characters are allowed. |
true
if the value only contains alphabetic characters Definition at line 56 of file validatoralpha.cpp.
References Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorAlpha::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 37 of file validatordomain.cpp.
References Cutelyst::ValidatorDomain::DashEnd, Cutelyst::ValidatorDomain::DashStart, Cutelyst::ValidatorDomain::DigitStart, Cutelyst::ValidatorDomain::DNSTimeout, Cutelyst::ValidatorDomain::EmptyLabel, Cutelyst::ValidatorDomain::InvalidChars, Cutelyst::ValidatorDomain::InvalidLabelCount, Cutelyst::ValidatorDomain::InvalidTLD, Cutelyst::ValidatorDomain::LabelTooLong, Cutelyst::ValidatorDomain::MissingDNS, Cutelyst::ValidatorDomain::TooLong, 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 34 of file validatorcharnotallowed.cpp.
References Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorCharNotAllowed::validate().
|
static |
value | The value to validate. |
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. You can use ValidatorPwQuality::errorString() to get a human readable string explaining the return value. Definition at line 36 of file validatorpwquality.cpp.
References 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 59 of file validatorip.cpp.
References Cutelyst::ValidatorIp::IPv4Only, 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 36 of file validatorfilesize.cpp.
References Cutelyst::ValidatorFileSize::ForceBinary, Cutelyst::ValidatorFileSize::ForceDecimal, Cutelyst::ValidatorFileSize::OnlyBinary, Cutelyst::ValidatorFileSize::OnlyDecimal, and Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorFileSize::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 67 of file validatordigits.cpp.
References Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorDigits::validate().
|
static |
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. Nothe that this might return true
for an empty value if 0 is between min and max. Definition at line 78 of file validatordigitsbetween.cpp.
References Cutelyst::ValidatorRule::value().
Referenced by Cutelyst::ValidatorDigitsBetween::validate().