6 #include "validatoremail_p.h"
19 u
"\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25["
20 "0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"_qs};
21 const QRegularExpression ValidatorEmailPrivate::ipv6PartRegex{u
"^[0-9A-Fa-f]{0,4}$"_qs};
22 const QString ValidatorEmailPrivate::stringSpecials{u
"()<>[]:;@\\,.\""_qs};
29 :
ValidatorRule(*new ValidatorEmailPrivate(field, threshold, options, messages, defValKey))
69 ValidatorEmailDiagnoseStruct diag;
71 if (ValidatorEmailPrivate::checkEmail(v, d->options, d->threshold, &diag)) {
72 if (!diag.literal.isEmpty()) {
82 result.
extra = QVariant::fromValue<QList<Diagnose>>(diag.returnStatus);
100 bool ValidatorEmailPrivate::checkEmail(
const QString &address,
101 ValidatorEmail::Options options,
103 ValidatorEmailDiagnoseStruct *diagnoseStruct)
107 EmailPart context = ComponentLocalpart;
109 EmailPart contextPrior = ComponentLocalpart;
119 int elementCount = 0;
121 bool hypenFlag =
false;
122 bool endOrDie =
false;
134 const QString domain = address.
mid(atPos + 1);
135 bool asciiDomain =
true;
136 for (
const QChar &ch : domain) {
137 const ushort &uc = ch.
unicode();
138 if (uc > ValidatorEmailPrivate::asciiEnd) {
156 const qsizetype rawLength = email.
length();
158 for (
int i = 0; i < rawLength; i++) {
165 case ComponentLocalpart:
185 if (elementLen == 0) {
195 contextStack.push_back(context);
196 context = ContextComment;
198 if (elementLen == 0) {
200 returnStatus.push_back((elementCount == 0)
215 parseLocalPart += token;
216 atomListLocalPart[elementCount] =
QString();
218 if (elementLen == 0) {
221 returnStatus.push_back((elementCount == 0)
225 parseLocalPart += token;
226 atomListLocalPart[elementCount] += token;
229 contextStack.push_back(context);
230 context = ContextQuotedString;
242 if (elementLen == 0) {
250 contextStack.push_back(context);
251 context = ContextFWS;
255 if (contextStack.size() != 1) {
257 qCCritical(C_VALIDATOR) <<
"ValidatorEmail: Unexpected item on context stack";
261 if (parseLocalPart.
isEmpty()) {
263 }
else if (elementLen == 0) {
265 }
else if (parseLocalPart.
size() > ValidatorEmailPrivate::maxLocalPartLength) {
270 }
else if ((contextPrior == ContextComment) || (contextPrior == ContextFWS)) {
284 context = ComponentDomain;
285 contextStack.clear();
286 contextStack.push_back(context);
305 switch (contextPrior) {
310 case ContextQuotedString:
315 qCCritical(C_VALIDATOR)
316 <<
"ValidatorEmail: More atext found where none is allowed, "
317 "but unrecognizes prior context";
321 contextPrior = context;
322 const char16_t uni = token.
unicode();
324 if (!allowUtf8Local) {
325 if ((uni < ValidatorEmailPrivate::asciiExclamationMark) ||
326 (uni > ValidatorEmailPrivate::asciiTilde) ||
327 ValidatorEmailPrivate::stringSpecials.contains(token)) {
328 returnStatus.push_back(
333 if ((uni < ValidatorEmailPrivate::asciiExclamationMark) ||
334 (uni > ValidatorEmailPrivate::asciiTilde) ||
335 ValidatorEmailPrivate::stringSpecials.contains(token)) {
336 returnStatus.push_back(
342 parseLocalPart += token;
343 atomListLocalPart[elementCount] += token;
351 case ComponentDomain:
392 if (elementLen == 0) {
396 returnStatus.push_back((elementCount == 0)
405 contextStack.push_back(context);
406 context = ContextComment;
408 if (elementLen == 0) {
410 returnStatus.push_back((elementCount == 0)
413 }
else if (hypenFlag) {
429 if (elementLen > ValidatorEmailPrivate::maxDnsLabelLength) {
438 atomListDomain[elementCount] =
QString();
439 parseDomain += token;
445 contextStack.push_back(context);
446 context = ComponentLiteral;
447 parseDomain += token;
448 atomListDomain[elementCount] += token;
461 if (elementLen == 0) {
462 returnStatus.push_back((elementCount == 0)
471 contextStack.push_back(context);
472 context = ContextFWS;
500 switch (contextPrior) {
505 case ComponentLiteral:
510 qCCritical(C_VALIDATOR)
511 <<
"ValidatorEmail: More atext found where none is allowed, but"
512 <<
"unrecognised prior context.";
517 const char16_t uni = token.
unicode();
520 if ((uni < ValidatorEmailPrivate::asciiExclamationMark) ||
521 (uni > ValidatorEmailPrivate::asciiTilde) ||
522 ValidatorEmailPrivate::stringSpecials.contains(token)) {
525 if (elementLen == 0) {
527 returnStatus.push_back(
531 }
else if (!(((uni >= ValidatorRulePrivate::ascii_0) &&
532 (uni <= ValidatorRulePrivate::ascii_9)) ||
533 ((uni >= ValidatorRulePrivate::ascii_A) &&
534 (uni <= ValidatorRulePrivate::ascii_Z)) ||
535 ((uni >= ValidatorRulePrivate::ascii_a) &&
536 (uni <= ValidatorRulePrivate::ascii_z)))) {
541 parseDomain += token;
542 atomListDomain[elementCount] += token;
549 case ComponentLiteral:
560 if (
static_cast<int>(
561 *std::max_element(returnStatus.constBegin(), returnStatus.constEnd())) <
617 qsizetype index = -1;
618 QString addressLiteral = parseLiteral;
621 ValidatorEmailPrivate::ipv4Regex.match(addressLiteral);
626 addressLiteral.
mid(0, index) +
636 addressLiteral.
left(5),
644 qsizetype groupCount = matchesIP.
size();
649 if (groupCount != maxGroups) {
656 if ((index == 0) || (index == (ipv6.
length() - 2))) {
660 if (groupCount > maxGroups) {
662 }
else if (groupCount == maxGroups) {
663 returnStatus.push_back(
672 returnStatus.push_back(
677 returnStatus.push_back(
681 int unmatchedChars = 0;
682 for (
const QString &ip : matchesIP) {
683 if (!ip.contains(ValidatorEmailPrivate::ipv6PartRegex)) {
687 if (unmatchedChars != 0) {
699 parseDomain += token;
700 atomListDomain[elementCount] += token;
702 contextPrior = context;
703 context = contextStack.takeLast();
706 contextStack.push_back(context);
707 context = ContextQuotedPair;
717 contextStack.push_back(context);
718 context = ContextFWS;
734 const char16_t uni = token.
unicode();
737 if ((uni > ValidatorEmailPrivate::asciiEnd) || (uni == 0) ||
741 }
else if ((uni < ValidatorEmailPrivate::asciiExclamationMark) ||
742 (uni == ValidatorEmailPrivate::asciiEnd)) {
746 parseLiteral += token;
747 parseDomain += token;
748 atomListDomain[elementCount] += token;
755 case ContextQuotedString:
764 contextStack.push_back(context);
765 context = ContextQuotedPair;
790 contextStack.push_back(context);
791 context = ContextFWS;
794 parseLocalPart += token;
795 atomListLocalPart[elementCount] += token;
797 contextPrior = context;
798 context = contextStack.takeLast();
813 const char16_t uni = token.
unicode();
815 if (!allowUtf8Local) {
816 if ((uni > ValidatorEmailPrivate::asciiEnd) || (uni == 0) ||
817 (uni == ValidatorEmailPrivate::asciiLF)) {
819 }
else if ((uni < ValidatorRulePrivate::asciiSpace) ||
820 (uni == ValidatorEmailPrivate::asciiEnd)) {
825 if ((uni > ValidatorEmailPrivate::asciiEnd) || (uni == 0) ||
826 (uni == ValidatorEmailPrivate::asciiLF)) {
827 returnStatus.push_back(
829 }
else if ((uni < ValidatorRulePrivate::asciiSpace) ||
830 (uni == ValidatorEmailPrivate::asciiEnd)) {
836 parseLocalPart += token;
837 atomListLocalPart[elementCount] += token;
852 case ContextQuotedPair:
870 const char16_t uni = token.
unicode();
872 if (uni > ValidatorEmailPrivate::asciiEnd) {
874 }
else if (((uni < ValidatorEmailPrivate::asciiUS) &&
875 (uni != ValidatorRulePrivate::asciiTab)) ||
876 (uni == ValidatorEmailPrivate::asciiEnd)) {
887 contextPrior = context;
888 context = contextStack.takeLast();
893 case ContextQuotedString:
895 parseLocalPart += token;
896 atomListLocalPart[elementCount] +=
QLatin1Char(
'\\');
897 atomListLocalPart[elementCount] += token;
901 case ComponentLiteral:
903 parseDomain += token;
905 atomListDomain[elementCount] += token;
911 qCCritical(C_VALIDATOR)
912 <<
"ValidatorEmail: Quoted pair logic invoked in an invalid context.";
927 contextStack.push_back(context);
928 context = ContextComment;
930 contextPrior = context;
931 context = contextStack.takeLast();
950 contextStack.push_back(context);
951 context = ContextQuotedPair;
961 contextStack.push_back(context);
962 context = ContextFWS;
979 const ushort uni = token.
unicode();
981 if ((uni > ValidatorEmailPrivate::asciiEnd) || (uni == 0) ||
982 (uni == ValidatorEmailPrivate::asciiLF)) {
985 }
else if ((uni < ValidatorRulePrivate::asciiSpace) ||
986 (uni == ValidatorEmailPrivate::asciiEnd)) {
1014 if (crlf_count > 0) {
1015 if (++crlf_count > 1) {
1016 returnStatus.push_back(
1035 if (crlf_count > 0) {
1039 contextPrior = context;
1040 context = contextStack.takeLast();
1066 qCCritical(C_VALIDATOR) <<
"ValidatorEmail: Unknown context";
1070 if (
static_cast<int>(
1071 *std::max_element(returnStatus.constBegin(), returnStatus.constEnd())) >
1078 if (
static_cast<int>(*std::max_element(returnStatus.constBegin(), returnStatus.constEnd())) <
1080 if (context == ContextQuotedString) {
1082 }
else if (context == ContextQuotedPair) {
1084 }
else if (context == ContextComment) {
1086 }
else if (context == ComponentLiteral) {
1090 }
else if (parseDomain.
isEmpty()) {
1092 }
else if (elementLen == 0) {
1094 }
else if (hypenFlag) {
1096 }
else if (parseDomain.
size() > ValidatorEmailPrivate::maxDomainLength) {
1100 }
else if ((parseLocalPart.
size() + 1 + parseDomain.
size()) >
1101 ValidatorEmailPrivate::maxMailboxLength) {
1121 }
else if (elementLen > ValidatorEmailPrivate::maxDnsLabelLength) {
1127 bool dnsChecked =
false;
1130 (
static_cast<int>(*std::max_element(returnStatus.constBegin(), returnStatus.constEnd())) <
1131 static_cast<int>(threshold))) {
1145 if (elementCount == 0) {
1156 if ((mxLookup.error() ==
QDnsLookup::NoError) && !mxLookup.mailExchangeRecords().empty()) {
1209 (
static_cast<int>(*std::max_element(returnStatus.constBegin(), returnStatus.constEnd())) <
1211 if (elementCount == 0) {
1215 if (QStringLiteral(
"0123456789").contains(atomListDomain[elementCount][0])) {
1220 if (returnStatus.size() != 1) {
1229 std::sort(returnStatus.begin(), returnStatus.end(), std::greater<>());
1234 if (diagnoseStruct) {
1235 diagnoseStruct->finalStatus = finalStatus;
1236 diagnoseStruct->returnStatus = returnStatus;
1237 diagnoseStruct->localpart = parseLocalPart;
1238 diagnoseStruct->domain = parseDomain;
1239 diagnoseStruct->literal = parseLiteral;
1242 return static_cast<int>(finalStatus) <
static_cast<int>(threshold);
1253 return c->
qtTrId(
"cutelyst-valemail-diag-valid");
1256 return c->
qtTrId(
"cutelyst-valemail-diag-nomx");
1259 return c->
qtTrId(
"cutelyst-valemail-diag-noarec");
1262 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321tld");
1265 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321tldnumeric");
1268 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321quotedstring");
1271 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321addressliteral");
1276 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321ipv6deprecated");
1279 return c->
qtTrId(
"cutelyst-valemail-diag-cfwscomment");
1282 return c->
qtTrId(
"cutelyst-valemail-diag-cfwsfws");
1285 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedlocalpart");
1288 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedfws");
1291 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedqtext");
1294 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedqp");
1297 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedcomment");
1300 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedctext");
1303 return c->
qtTrId(
"cutelyst-valemail-diag-cfwsnearat");
1307 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domain");
1310 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322toolong")
1315 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322localtoolong")
1319 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domaintoolong")
1324 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322labeltoolong")
1328 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domainliteral");
1332 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domlitobsdtext");
1335 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6groupcount");
1338 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv62x2xcolon");
1341 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6badchar");
1344 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6maxgroups");
1347 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6colonstart");
1350 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6colonend");
1353 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingdtext");
1356 return c->
qtTrId(
"cutelyst-valemail-diag-errnolocalpart");
1359 return c->
qtTrId(
"cutelyst-valemail-diag-errnodomain");
1362 return c->
qtTrId(
"cutelyst-valemail-diag-errconsecutivedots");
1365 return c->
qtTrId(
"cutelyst-valemail-diag-erratextaftercfws");
1368 return c->
qtTrId(
"cutelyst-valemail-diag-erratextafterqs");
1371 return c->
qtTrId(
"cutelyst-valemail-diag-erratextafterdomlit");
1374 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingqpair");
1377 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingatext");
1380 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingqtext");
1383 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingctext");
1386 return c->
qtTrId(
"cutelyst-valemail-diag-errbackslashend");
1389 return c->
qtTrId(
"cutelyst-valemail-diag-errdotstart");
1392 return c->
qtTrId(
"cutelyst-valemail-diag-errdotend");
1395 return c->
qtTrId(
"cutelyst-valemail-diag-errdomainhyphenstart");
1398 return c->
qtTrId(
"cutelyst-valemail-diag-errdomainhyphenend");
1401 return c->
qtTrId(
"cutelyst-valemail-diag-errunclosedquotedstr");
1404 return c->
qtTrId(
"cutelyst-valemail-diag-errunclosedcomment");
1407 return c->
qtTrId(
"cutelyst-valemail-diag-erruncloseddomliteral");
1410 return c->
qtTrId(
"cutelyst-valemail-diag-errfwscrlfx2");
1413 return c->
qtTrId(
"cutelyst-valemail-diag-errfwscrlfend");
1417 return c->
qtTrId(
"cutelyst-valemail-diag-errcrnolf");
1420 return c->
qtTrId(
"cutelyst-valemail-diag-errfatal");
1432 return c->
qtTrId(
"cutelyst-valemail-diag-valid-label").
arg(
label);
1436 return c->
qtTrId(
"cutelyst-valemail-diag-nomx-label").
arg(
label);
1440 return c->
qtTrId(
"cutelyst-valemail-diag-noarec-label").
arg(
label);
1443 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321tld-label").
arg(
label);
1447 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321tldnumeric-label").
arg(
label);
1450 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321quotedstring-label").
arg(
label);
1454 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321addressliteral-label").
arg(
label);
1459 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5321ipv6deprecated-label").
arg(
label);
1462 return c->
qtTrId(
"cutelyst-valemail-diag-cfwscomment-label").
arg(
label);
1466 return c->
qtTrId(
"cutelyst-valemail-diag-cfwsfws-label").
arg(
label);
1469 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedlocalpart-label").
arg(
label);
1473 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedfws-label").
arg(
label);
1477 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedqtext-label").
arg(
label);
1481 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedqp-label").
arg(
label);
1485 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedcomment-label").
arg(
label);
1488 return c->
qtTrId(
"cutelyst-valemail-diag-deprecatedctext-label").
arg(
label);
1492 return c->
qtTrId(
"cutelyst-valemail-diag-cfwsnearat-label").
arg(
label);
1496 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domain-label").
arg(
label);
1500 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322toolong-label")
1505 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322localtoolong-label")
1510 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domaintoolong-label")
1515 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322labeltoolong-label")
1520 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domainliteral-label").
arg(
label);
1524 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322domlitobsdtext-label").
arg(
label);
1528 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6groupcount-label").
arg(
label);
1532 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv62x2xcolon-label").
arg(
label);
1536 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6badchar-label").
arg(
label);
1539 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6maxgroups-label").
arg(
label);
1543 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6colonstart-label").
arg(
label);
1547 return c->
qtTrId(
"cutelyst-valemail-diag-rfc5322ipv6colonend-label").
arg(
label);
1551 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingdtext-label").
arg(
label);
1554 return c->
qtTrId(
"cutelyst-valemail-diag-errnolocalpart-label").
arg(
label);
1557 return c->
qtTrId(
"cutelyst-valemail-diag-errnodomain-label").
arg(
label);
1560 return c->
qtTrId(
"cutelyst-valemail-diag-errconsecutivedots-label").
arg(
label);
1564 return c->
qtTrId(
"cutelyst-valemail-diag-erratextaftercfws-label").
arg(
label);
1567 return c->
qtTrId(
"cutelyst-valemail-diag-erratextafterqs-label").
arg(
label);
1571 return c->
qtTrId(
"cutelyst-valemail-diag-erratextafterdomlit-label").
arg(
label);
1575 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingqpair-label").
arg(
label);
1578 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingatext-label").
arg(
label);
1582 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingqtext-label").
arg(
label);
1586 return c->
qtTrId(
"cutelyst-valemail-diag-errexpectingctext-label").
arg(
label);
1589 return c->
qtTrId(
"cutelyst-valemail-diag-errbackslashend-label").
arg(
label);
1592 return c->
qtTrId(
"cutelyst-valemail-diag-errdotstart-label").
arg(
label);
1595 return c->
qtTrId(
"cutelyst-valemail-diag-errdotend-label").
arg(
label);
1599 return c->
qtTrId(
"cutelyst-valemail-diag-errdomainhyphenstart-label").
arg(
label);
1603 return c->
qtTrId(
"cutelyst-valemail-diag-errdomainhyphenend-label").
arg(
label);
1607 return c->
qtTrId(
"cutelyst-valemail-diag-errunclosedquotedstr-label").
arg(
label);
1611 return c->
qtTrId(
"cutelyst-valemail-diag-errunclosedcomment-label").
arg(
label);
1615 return c->
qtTrId(
"cutelyst-valemail-diag-erruncloseddomliteral-label").
arg(
label);
1619 return c->
qtTrId(
"cutelyst-valemail-diag-errfwscrlfx2-label").
arg(
label);
1623 return c->
qtTrId(
"cutelyst-valemail-diag-errfwscrlfend-label").
arg(
label);
1627 return c->
qtTrId(
"cutelyst-valemail-diag-errcrnolf-label").
arg(
label);
1630 return c->
qtTrId(
"cutelyst-valemail-diag-errfatal-label").
arg(
label);
1643 return c->
qtTrId(
"cutelyst-valemail-cat-valid");
1646 return c->
qtTrId(
"cutelyst-valemail-cat-dnswarn");
1649 return c->
qtTrId(
"cutelyst-valemail-cat-rfc5321");
1653 return c->
qtTrId(
"cutelyst-valemail-cat-cfws");
1657 return c->
qtTrId(
"cutelyst-valemail-cat-deprecated");
1661 return c->
qtTrId(
"cutelyst-valemail-cat-rfc5322");
1664 return c->
qtTrId(
"cutelyst-valemail-cat-invalid");
1670 return c->
qtTrId(
"cutelyst-valemail-cat-valid-label").
arg(
label);
1673 return c->
qtTrId(
"cutelyst-valemail-cat-dnswarn-label").
arg(
label);
1676 return c->
qtTrId(
"cutelyst-valemail-cat-rfc5321-label").
arg(
label);
1684 return c->
qtTrId(
"cutelyst-valemail-cat-deprecated-label").
arg(
label);
1688 return c->
qtTrId(
"cutelyst-valemail-cat-rfc5322-label").
arg(
label);
1691 return c->
qtTrId(
"cutelyst-valemail-cat-invalid-label").
arg(
label);
1700 const auto diag =
static_cast<int>(diagnose);
1702 if (diag <
static_cast<int>(
Valid)) {
1704 }
else if (diag <
static_cast<int>(
DNSWarn)) {
1706 }
else if (diag <
static_cast<int>(
RFC5321)) {
1708 }
else if (diag <
static_cast<int>(
CFWS)) {
1710 }
else if (diag <
static_cast<int>(
Deprecated)) {
1712 }
else if (diag <
static_cast<int>(
RFC5322)) {
1729 ValidatorEmailDiagnoseStruct diag;
1730 bool ret = ValidatorEmailPrivate::checkEmail(email, options, threshold, &diag);
1733 *diagnoses = diag.returnStatus;
1739 #include "moc_validatoremail.cpp"
QLocale locale() const noexcept
QString qtTrId(const char *id, int n=-1) const
Checks if the value is a valid email address according to specific RFCs.
static Category category(Diagnose diagnose)
Category
Validation category, used as threshold to define valid addresses.
~ValidatorEmail() override
Diagnose
Single diagnose values that show why an address is not valid.
@ ErrorUnclosedDomLiteral
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
static QString categoryString(Context *c, Category category, const QString &label={})
static QString diagnoseString(Context *c, Diagnose diagnose, const QString &label={})
ValidatorEmail(const QString &field, Category threshold=RFC5321, Options options=NoOption, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Base class for all validator rules.
QString validationError(Context *c, const QVariant &errorData={}) const
QString label(Context *c) const
void defaultValue(Context *c, ValidatorReturnType *result) const
QString value(const ParamsMultiMap ¶ms) const
static bool 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.
The Cutelyst namespace holds all public Cutelyst API.
bool isLetterOrNumber(char32_t ucs4)
int exec(QEventLoop::ProcessEventsFlags flags)
void append(QList::parameter_type value)
bool contains(const AT &value) const const
qsizetype size() const const
QString toString(QDate date, QLocale::FormatType format) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString captured(QStringView name) const const
bool hasMatch() const const
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
QString fromLatin1(QByteArrayView str)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString right(qsizetype n) const const
qsizetype size() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
const QChar * unicode() const const
QByteArray toAce(const QString &domain, QUrl::AceProcessingOptions options)
void setValue(QVariant &&value)
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.