MCPcopy Create free account
hub / github.com/cutelyst/cutelyst / fileSizeValue

Method fileSizeValue

tests/testvalidator.cpp:759–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

757 // ***** Endpoint for ValidatorFileSize with return value check *****
758 C_ATTR(fileSizeValue, :Local :AutoArgs)
759 void fileSizeValue(Context *c)
760 {
761 c->setLocale(QLocale::c());
762 Validator v({new ValidatorFileSize(u"field"_s)});
763 const ValidatorResult r = v.validate(c);
764 if (r) {
765 QString sizeString;
766 const QVariant rv = r.value(u"field"_s);
767 if (rv.typeId() == QMetaType::Double) {
768 sizeString = QString::number(rv.toDouble(), 'f', 2);
769 } else {
770 sizeString = QString::number(rv.toULongLong());
771 }
772 c->response()->setBody(sizeString.toUtf8());
773 } else {
774 c->response()->setBody(r.errorStrings().constFirst());
775 }
776 }
777
778 // ***** Endpoint for ValidatorFilled ******
779 C_ATTR(filled, :Local :AutoArgs)

Callers

nothing calls this directly

Calls 6

setLocaleMethod · 0.80
responseMethod · 0.80
errorStringsMethod · 0.80
setBodyMethod · 0.60
validateMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected