lib/index.js
function validate(cmd, args, info) {
  info = info || {};
  var conf = info.conf || {}
    , authrequired = typeof conf.requirepass === 'string'
    , db = info.db
    , result;

  // handle quit command special case
  if(cmd === COMMANDS.QUIT) {
    // reply with an object that mimics succesful validation
    info.command = {
      cmd: cmd, args: args, def: Constants.MAP.quit, arity: true};
    return info;
  // validate command is known
  }else{
    info.command = validators.command(cmd, args, info);
  }

  // check args length (arity)
  info.command.arity = validators.arity(cmd, args, info);

  // handle authentication requests
  if(cmd === COMMANDS.AUTH) {
    info.conn.authenticated =
      validators.auth(cmd, args, info);
  // handle unauthenticated requests when auth is enabled
  }else if(authrequired && !info.conn.authenticated) {
    throw AuthRequired;
  }

  // check operation on the correct type of value
  // this validation extracts keys, looks up the values
  // to determine the type of the existing value
  // the val array (or null) is assigned to the command
  // info object so that calling code may re-use it and
  // save looking up keys and values again where necessary
  info.command.value = validators.type(cmd, args, info);

  return info;
}
function validate(cmd, args, info) {
  info = info || {};
  var conf = info.conf || {}
    , authrequired = typeof conf.requirepass === 'string'
    , db = info.db
    , result;

  // handle quit command special case
  if(cmd === COMMANDS.QUIT) {
    // reply with an object that mimics succesful validation
    info.command = {
      cmd: cmd, args: args, def: Constants.MAP.quit, arity: true};
    return info;
  // validate command is known
  }else{
    info.command = validators.command(cmd, args, info);
  }

  // check args length (arity)
  info.command.arity = validators.arity(cmd, args, info);

  // handle authentication requests
  if(cmd === COMMANDS.AUTH) {
    info.conn.authenticated =
      validators.auth(cmd, args, info);
  // handle unauthenticated requests when auth is enabled
  }else if(authrequired && !info.conn.authenticated) {
    throw AuthRequired;
  }

  // check operation on the correct type of value
  // this validation extracts keys, looks up the values
  // to determine the type of the existing value
  // the val array (or null) is assigned to the command
  // info object so that calling code may re-use it and
  // save looking up keys and values again where necessary
  info.command.value = validators.type(cmd, args, info);

  return info;
}
function validate ( cmd , args , info ) { info = info || { } ; var conf = info . conf || { } , authrequired = typeof conf . requirepass === 'string' , db = info . db , result ; // handle quit command special case if ( cmd === COMMANDS . QUIT ) { // reply with an object that mimics succesful validation info . command = { cmd : cmd , args : args , def : Constants . MAP . quit , arity : true } ; return info ; // validate command is known } else { info . command = validators . command ( cmd , args , info ) ; } // check args length (arity) info . command . arity = validators . arity ( cmd , args , info ) ; // handle authentication requests if ( cmd === COMMANDS . AUTH ) { info . conn . authenticated = validators . auth ( cmd , args , info ) ; // handle unauthenticated requests when auth is enabled } else if ( authrequired && ! info . conn . authenticated ) { throw AuthRequired ; } // check operation on the correct type of value // this validation extracts keys, looks up the values // to determine the type of the existing value // the val array (or null) is assigned to the command // info object so that calling code may re-use it and // save looking up keys and values again where necessary info . command . value = validators . type ( cmd , args , info ) ; return info ; }
Performs complete validation for an incoming command.

The command name should be lowercase.

@param cmd The command name.
@param args The command arguments.
@param info The configuration and current database pointer.
Performs complete validation for an incoming command .