For your customerValidation function, I would prefer to write my function validating the fields separately. All fields are required but the name is checked only if the login is checked only if the email is checked. I don't think the ternary operator is appropriate for this usecase.
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
For validation, I would actually use something like Joi.
This is a problem with contrived examples. You think of a technique you want to demonstrate, then you find an example that will demonstrate it. Most times, there are better ways to solve the example you used. But those other ways, do not demonstrate the technique you wanted to demonstrate.
My goal was to demonstrate the ternary, not to show input validation.
I probably should have used some obscure cat example. Something I need to work on for sure.
Cheers!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For your
customerValidation
function, I would prefer to write my function validating the fields separately. All fields are required but thename
is checked only if thelogin
is checked only if theemail
is checked. I don't think the ternary operator is appropriate for this usecase.Absolutely!
For validation, I would actually use something like Joi.
This is a problem with contrived examples. You think of a technique you want to demonstrate, then you find an example that will demonstrate it. Most times, there are better ways to solve the example you used. But those other ways, do not demonstrate the technique you wanted to demonstrate.
My goal was to demonstrate the ternary, not to show input validation.
I probably should have used some obscure cat example. Something I need to work on for sure.
Cheers!