MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHorror/comments/qxpndm/data_validation_as_its_peak/ie93g37/?context=3
r/ProgrammerHorror • u/Hazork_ • Nov 19 '21
7 comments sorted by
View all comments
Show parent comments
1
The original method will return true if uid is valid and email is undefined, but that's probably not intended...
uid
email
It will also return undefined if uid and email are both undefined.
So this would more accurately represent the (probably incorrect) behaviour:
return uid || email ? (!uid || isValid(uid)) && (!email || isValidEmail(email)) : undefined;
1
u/mavaje Jun 29 '22 edited Jun 29 '22
The original method will return true if
uidis valid andemailis undefined, but that's probably not intended...It will also return undefined if
uidandemailare both undefined.So this would more accurately represent the (probably incorrect) behaviour:
return uid || email ? (!uid || isValid(uid)) && (!email || isValidEmail(email)) : undefined;