lib/command/database/string/set.js
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var offset = 2
    , arg
    , expires;

  // need string args (except for key, value)
  args.forEach(function(a, i, arr) {
    if(i > 1) {
      arr[i] = '' + a;
    }
  })

  if(args.length > 7) {
    throw new CommandArgLength(cmd);
  }else if(args.length > 2) {
    arg = args[offset];
    while(arg !== undefined) {
      arg = arg.toLowerCase();
      args[offset] = arg;
      if(arg !== Constants.EX
        && arg !== Constants.PX
        && arg !== Constants.NX
        && arg !== Constants.XX) {
        throw CommandSyntax;
      }
      if(arg === Constants.EX || arg === Constants.PX) {
        expires = parseInt('' + args[offset + 1]);
        if(isNaN(expires)) {
          throw IntegerRange;
        }
        args[++offset] = expires;
      }
      arg = args[++offset];
    }
  }
}
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var offset = 2
    , arg
    , expires;

  // need string args (except for key, value)
  args.forEach(function(a, i, arr) {
    if(i > 1) {
      arr[i] = '' + a;
    }
  })

  if(args.length > 7) {
    throw new CommandArgLength(cmd);
  }else if(args.length > 2) {
    arg = args[offset];
    while(arg !== undefined) {
      arg = arg.toLowerCase();
      args[offset] = arg;
      if(arg !== Constants.EX
        && arg !== Constants.PX
        && arg !== Constants.NX
        && arg !== Constants.XX) {
        throw CommandSyntax;
      }
      if(arg === Constants.EX || arg === Constants.PX) {
        expires = parseInt('' + args[offset + 1]);
        if(isNaN(expires)) {
          throw IntegerRange;
        }
        args[++offset] = expires;
      }
      arg = args[++offset];
    }
  }
}
function validate ( cmd , args , info ) { AbstractCommand . prototype . validate . apply ( this , arguments ) ; var offset = 2 , arg , expires ; // need string args (except for key, value) args . forEach ( function ( a , i , arr ) { if ( i > 1 ) { arr [ i ] = '' + a ; } } ) if ( args . length > 7 ) { throw new CommandArgLength ( cmd ) ; } else if ( args . length > 2 ) { arg = args [ offset ] ; while ( arg !== undefined ) { arg = arg . toLowerCase ( ) ; args [ offset ] = arg ; if ( arg !== Constants . EX && arg !== Constants . PX && arg !== Constants . NX && arg !== Constants . XX ) { throw CommandSyntax ; } if ( arg === Constants . EX || arg === Constants . PX ) { expires = parseInt ( '' + args [ offset + 1 ] ) ; if ( isNaN ( expires ) ) { throw IntegerRange ; } args [ ++ offset ] = expires ; } arg = args [ ++ offset ] ; } } }
Validate the SET command.
Validate the SET command .