Electron user data validation


#1

How would you guys validate user data from a simple login/signup form that has email, password and maybe name fields, using a form. On nodejs, you could use express-validator, but that is server sided, how would I have the same mechanism in electron?
Or could I send request to a server and validate there and bring back errors to the user?


#2

Electron can do all of the normal Node things. I don’t know if express-validator is reliant on other parts of Express or not, but if it’s not, then it should be usable. If not, it’s really not difficult to write a validation algorithm in JavaScript.


#3

As far as I can tell, express-validator is used in combination with requests, meaning that I’ll have to move the validation mechanism to the server side.


#4

I think there’s something you missed. Specifically, the first line of the readme for express-validator. The validator library doesn’t have any weird server requirements.


#5

I will look into it and give back an update.


#6

The thing is, the examples on the repo are done on request fields… That’s why I am bound to think the module is mainly used like this…


#7

You’re still looking at express-validator and you shouldn’t be. It’s designed to serve a specific purpose for a web server package, express. What you want to write your validator is to require validator and use its functions to check input.


#8

Thanks for the input. I’ll try to code a validation mechanism using validator.