|
if (!body?.username || typeof body?.username !== 'string' || !body?.username.length > 0) { |
|
return res.status(400).json({ message: 'Parameters were invalid', details: [{ param: 'username', msg: 'Parameter must be a non empty string' }] }) |
|
} |
body?.username already checks for a nonzero length because "" is falsy.
!body?.username.length > 0 means to convert a zero length to true and convert any other length to false, and then compare that boolean to zero. Because this code is reached only when the length is nonzero,
|| !body?.username.length > 0
is always equivalent to:
and can be omitted.
cve-services/src/controller/org.controller/org.controller.js
Lines 451 to 453 in 69b2859
body?.username already checks for a nonzero length because "" is falsy.
!body?.username.length > 0means to convert a zero length to true and convert any other length to false, and then compare that boolean to zero. Because this code is reached only when the length is nonzero,is always equivalent to:
and can be omitted.