DEV Community


Discussion on: Back to basics: Naming

katylava profile image
katy lavallee

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.

sadick profile image
Sadick Author

isValidEmail added. Thanks for the feedback.

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 that may be a valid email address but it's not valid for use as such in the context of your app.