DEV Community

Discussion on: Back to basics: Naming

Collapse
 
katylava profile image
katy lavallee • Edited

Not listed, but I would use isValidEmail. is* is a good way to indicate true/false return value. And if (isValidEmail) reads well.

I would not use validateEmail because I would expect an error message in return, not a boolean.

I would not use isEmail because it sounds weird and unclear to me. I can’t put my finger on why though.

I would not use emailIsValid because I assume there would be a series of functions like this, and I would like their names to all start same.

Collapse
 
moopet profile image
Ben Sinclair

isEmail sounds weird because it's too generic. For most purposes you'll be validating a user's input, and if they put in foo@example.com that may be a valid email address but it's not valid for use as such in the context of your app.

Collapse
 
sadick profile image
Sadick

isValidEmail added. Thanks for the feedback.