[GH-ISSUE #736] Custom Parameter with validation #614

Closed
opened 2026-02-28 01:26:13 +03:00 by kerem · 7 comments
Owner

Originally created by @marsrakete on GitHub (Sep 17, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/736

Kindly asking for Feature Request

I was implementing WiFiManagerParameter for a project. Works really good! Until I discovered, that I accidentally left the MQTT-field empty. Which made it quite hard to change afterwards (had to switch of the Wifi-router to be able to connect to the ESP).

My suggestion is to integrate some basic validation method like:

  • field is required, not empty.
  • field must contain IP address
  • field must contain mail address
  • field must be validated by custom callback
    ...

If validation fails, the first input form is re-displayed, with error message(s).
Of course very rudimentary.

Hence new parameter like:
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40, REQUIRED | IP_ADDRESS);

(Bit-operation not required, just an idea. Might be confusing)

WiFimanager Branch/Release:

  • [x ] Master
  • Development

Esp8266/Esp32:

  • [x ] ESP8266
  • ESP32
Originally created by @marsrakete on GitHub (Sep 17, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/736 Kindly asking for Feature Request I was implementing WiFiManagerParameter for a project. Works really good! Until I discovered, that I accidentally left the MQTT-field empty. Which made it quite hard to change afterwards (had to switch of the Wifi-router to be able to connect to the ESP). My suggestion is to integrate some basic validation method like: - field is required, not empty. - field must contain IP address - field must contain mail address - field must be validated by custom callback ... If validation fails, the first input form is re-displayed, with error message(s). Of course very rudimentary. Hence new parameter like: WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40, REQUIRED | IP_ADDRESS); (Bit-operation not required, just an idea. Might be confusing) **WiFimanager Branch/Release:** - [x ] Master - [ ] Development **Esp8266/Esp32:** - [x ] ESP8266 - [ ] ESP32
kerem 2026-02-28 01:26:13 +03:00
Author
Owner

@tablatronix commented on GitHub (Sep 17, 2018):

just add'required attributes to the html..

<!-- gh-comment-id:422126017 --> @tablatronix commented on GitHub (Sep 17, 2018): just add`'required` attributes to the html..
Author
Owner

@tablatronix commented on GitHub (Sep 18, 2018):

  • add param validation callbacks
<!-- gh-comment-id:422408400 --> @tablatronix commented on GitHub (Sep 18, 2018): - [ ] add param validation callbacks
Author
Owner

@marsrakete commented on GitHub (Sep 18, 2018):

The "required" attribute is not sufficient and requires manual changes in the WiFiManager.h, which is likely impractical when using the IDE and the library manager.
I guess the callback-method is the most practical way.

<!-- gh-comment-id:422420799 --> @marsrakete commented on GitHub (Sep 18, 2018): The "required" attribute is not sufficient and requires manual changes in the WiFiManager.h, which is likely impractical when using the IDE and the library manager. I guess the callback-method is the most practical way.
Author
Owner

@tablatronix commented on GitHub (Sep 18, 2018):

well not really, the param class allows custom html attributes
WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {

also development branch contains all html in a strings.h file not source code

<!-- gh-comment-id:422442536 --> @tablatronix commented on GitHub (Sep 18, 2018): well not really, the param class allows custom html attributes `WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) { ` also development branch contains all html in a strings.h file not source code
Author
Owner

@marsrakete commented on GitHub (Sep 18, 2018):

Wow, development branch has greatly evolved!
Somehow I wasn’t aware about the custom html parameter. Now I read the class code, I understand what you’ve done by overloading.

Thank you. I’ll be patiently awaiting new master release. Issue may be closed.

<!-- gh-comment-id:422456032 --> @marsrakete commented on GitHub (Sep 18, 2018): Wow, development branch has greatly evolved! Somehow I wasn’t aware about the custom html parameter. Now I read the class code, I understand what you’ve done by overloading. Thank you. I’ll be patiently awaiting new master release. Issue may be closed.
Author
Owner

@tablatronix commented on GitHub (Sep 18, 2018):

for example
WiFiManagerParameter custom_ipaddress("input_ip", "input IP", "", 19,"pattern='\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'");

you can also pass in the entire parameter as custom html
with WiFiManagerParameter custom_html("<p>This Is Custom HTML</p>");

<!-- gh-comment-id:422462435 --> @tablatronix commented on GitHub (Sep 18, 2018): for example ` WiFiManagerParameter custom_ipaddress("input_ip", "input IP", "", 19,"pattern='\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'"); ` you can also pass in the entire parameter as custom html with `WiFiManagerParameter custom_html("<p>This Is Custom HTML</p>");`
Author
Owner

@tablatronix commented on GitHub (Oct 5, 2018):

you can now add custom param child classes #741

<!-- gh-comment-id:427442245 --> @tablatronix commented on GitHub (Oct 5, 2018): you can now add custom param child classes #741
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#614
No description provided.