me-no-dev / ESPAsyncWebServer

Async Web Server for ESP8266 and ESP32
3.76k stars 1.22k forks source link

Form validation class? #701

Closed nardev closed 4 years ago

nardev commented 4 years ago

As there is more and more http rest style of communication, it's pretty logical to have a class for basic validations in C++.

I tried to find something, but no luck so far. It's ok to implement it from time to time, copy/paste some functions but it would be much better maintained and probably safer if there was an opensource class, openly maintained, where bugs could be tracked and fixed.

Did i miss something like that already?

For example, i would like to be to easily validate:

and, maybe someone else have more ideas.

Any thoughts?

Pablo2048 commented 4 years ago

Hi, you can use html5 validators in your html/js code. I think that validating form input at the server side of web application is depreceated - in case of wrong input there is big overhead to bring everything back to the client and highlight errors IMHO.

nardev commented 4 years ago

Well, if you don't have web interface but a rest API? Or if you decide to send json formated config file with a lot of data via POST?

On Tue, Feb 11, 2020, 6:14 AM Pablo2048 notifications@github.com wrote:

Hi, you can use html5 validators in your html/js code. I think that validating form input at the server side of web application is depreceated

  • in case of wrong input there is big overhead to bring everything back to the client and highlight errors IMHO.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/me-no-dev/ESPAsyncWebServer/issues/701?email_source=notifications&email_token=AAFJ55TDJKRMY2HWK4GL4C3RCIX4NA5CNFSM4KSZI262YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELLHSAA#issuecomment-584481024, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFJ55X3ORN4IRNCJLHLGW3RCIX4NANCNFSM4KSZI26Q .

Pablo2048 commented 4 years ago

If you do so this way, you have to write separate library for doing this. It has nothing to do with the ESPAsyncWebServer library. Also this is not "Form validation" neither...

nardev commented 4 years ago

Well, you are right of course. But where else can i initiate such conversation? Isn't this the perfect place :)

Pablo2048 commented 4 years ago

:-) I suggest to try esp8266.com , or reddit, or... I did an quick search for "parameter validation library c++" and found this https://www.learncpp.com/cpp-tutorial/185-stream-states-and-input-validation/ so it seems like regex implementation is the best way to do it :D

nardev commented 4 years ago

mmm i think that you didn't understand my point... sorry

Pablo2048 commented 4 years ago

Oh, so sorry...

stale[bot] commented 4 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.