Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function validatePromoteRequest(clusterState)
{
var promote, error, expireTime;
promote = mod_jsprim.pluck(clusterState, 'promote');
if (!promote)
return (undefined);
error = validateAndCopy(schemas.promote, promote);
if (error instanceof Error)
return (error);
expireTime = mod_jsprim.parseDateTime(promote.expireTime);
if (isNaN(expireTime.getTime())) {
return (new VError('expireTime is not parseable (found "%s")',
promote.expireTime));
}
if (promote.generation !== clusterState.generation) {
return (new VError('generation does not match (expected %d, ' +
'found %d)', clusterState.generation, promote.generation));
}
if (expireTime.getTime() < new Date().getTime())
return (new VError('expireTime has passed ("%s")',
promote.expireTime));
if (promote.role === 'async') {
if (!promote.hasOwnProperty('asyncIndex')) {