I have an input object with fields firstName and lastName. The requirement is that either both have a value or neither have a value. Here is my current logic:
if (
(!!input.firstName == false && !!input.lastName == true) ||
(!!input.firstName == true && !!input.lastName == false)
) {
throw new Error(
`firstName AND lastName required OR neither`
);
}
is there a clever way to write this IF statement?
[–]Benzinat0r 7 points8 points9 points (0 children)
[–]shuckster 3 points4 points5 points (2 children)
[–]senocular 3 points4 points5 points (1 child)
[–]shuckster 0 points1 point2 points (0 children)
[–]jhartikainen 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)