esphome / esphome

ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
https://esphome.io/
Other
8.31k stars 3.51k forks source link

[Feature Request] Input validation #56

Closed mrand closed 5 years ago

mrand commented 6 years ago

When a user enters a device name with upper-case characters, it fails to validate or compile. But since the plugin doesn't appear to have a way to go back and edit the file, they will have to go to a configuration editor or jump over to command line to fix it.

The failure could be avoided in the first place if ESPhomeYAML did a first pass simple validation on the input field in initial config, or else did an automatic conversion to lower-case.

balk77 commented 6 years ago

Same for spaces in the name

OttoWinter commented 6 years ago

I understand the problem and real input validation would be great. However I have no idea how to do it with the material stepper library I used; probably it's somehow possible with the jquery validation plugin it uses, but I don't know how.

If someone knows how to do it, then a PR to fix this behavior would be very much appreciated. I personally just don't think this is that big of a problem and don't want to have to debug weird javascript errors for many more hours (I'm a quite inexperienced web developer).

To address the issue though I would propose to do some "social" hacking by changing the

It may only contain the characters a-z, 0-9 and _

message on that screen to a

Names must be lowercase and must not contain spaces (allowed characters: a-z, 0-9 and _)

balk77 commented 6 years ago

Excellent resolution :)