From b857812bfe5bd2d82fde4b4cf59e84564aac383d Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Thu, 14 Nov 2019 20:42:38 +0100 Subject: [PATCH] Added support for FormValidator to IotWebConf --- lib/IotWebConf/src/IotWebConf.cpp | 8 ++++++++ lib/IotWebConf/src/IotWebConf.h | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/IotWebConf/src/IotWebConf.cpp b/lib/IotWebConf/src/IotWebConf.cpp index 8780095..528614d 100644 --- a/lib/IotWebConf/src/IotWebConf.cpp +++ b/lib/IotWebConf/src/IotWebConf.cpp @@ -362,7 +362,11 @@ void IotWebConf::setConfigSavedCallback(std::function func) this->_configSavedCallback = func; } +#ifndef USE_ESPASYNCWEBSERVER void IotWebConf::setFormValidator(std::function func) +#else +void IotWebConf::setFormValidator(std::function func) +#endif { this->_formValidator = func; } @@ -683,7 +687,11 @@ boolean IotWebConf::validateForm(AsyncWebServerRequest* request) boolean valid = true; if (this->_formValidator != NULL) { +#ifndef USE_ESPASYNCWEBSERVER valid = this->_formValidator(); +#else + valid = this->_formValidator(request); +#endif } // -- Internal validation. diff --git a/lib/IotWebConf/src/IotWebConf.h b/lib/IotWebConf/src/IotWebConf.h index 424a4d5..679c0a9 100644 --- a/lib/IotWebConf/src/IotWebConf.h +++ b/lib/IotWebConf/src/IotWebConf.h @@ -325,8 +325,11 @@ public: * If the method will return false, the configuration will not be saved. * Should be called before init()! */ +#ifndef USE_ESPASYNCWEBSERVER void setFormValidator(std::function func); - +#else + void setFormValidator(std::function func); +#endif /** * Specify your custom Access Point connection handler. Please use IotWebConf::connectAp() as * reference when implementing your custom solution. @@ -531,7 +534,11 @@ private: byte _apConnectionStatus = IOTWEBCONF_AP_CONNECTION_STATE_NC; std::function _wifiConnectionCallback = NULL; std::function _configSavedCallback = NULL; +#ifndef USE_ESPASYNCWEBSERVER std::function _formValidator = NULL; +#else + std::function _formValidator = NULL; +#endif std::function _apConnectionHandler = &(IotWebConf::connectAp); std::function _wifiConnectionHandler =