lib/command/database/key/scan.js
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var offset = info.exec.offset
    , arg = args[offset];

  if(args.length > offset + 4) {
    throw new CommandArgLength(info.exec.definition.name);
  }

  // cursor already parsed to integer by numeric validation
  info.cursor = args[offset - 1]

  //console.dir(args);

  if(arg !== undefined) {
    arg = (('' + arg).toLowerCase());
    while(arg !== undefined) {
      //console.dir(arg);
      if(arg !== Constants.SCAN.MATCH && arg !== Constants.SCAN.COUNT) {
        throw CommandSyntax;
      }else if(arg === Constants.SCAN.MATCH) {
        /* istanbul ignore next: really tough to get a pattern compile error! */
        try {
          info.pattern = Pattern.compile(args[offset + 1]);
        }catch(e) {
          throw PatternCompile;
        }
      // should be on count arg
      }else{
        info.count = parseInt('' + args[offset + 1]);
        if(isNaN(info.count)) {
          throw IntegerRange;
        }
      }
      offset+=2;
      arg = args[offset] ? '' + args[offset] : undefined;
    }
  }
}
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var offset = info.exec.offset
    , arg = args[offset];

  if(args.length > offset + 4) {
    throw new CommandArgLength(info.exec.definition.name);
  }

  // cursor already parsed to integer by numeric validation
  info.cursor = args[offset - 1]

  //console.dir(args);

  if(arg !== undefined) {
    arg = (('' + arg).toLowerCase());
    while(arg !== undefined) {
      //console.dir(arg);
      if(arg !== Constants.SCAN.MATCH && arg !== Constants.SCAN.COUNT) {
        throw CommandSyntax;
      }else if(arg === Constants.SCAN.MATCH) {
        /* istanbul ignore next: really tough to get a pattern compile error! */
        try {
          info.pattern = Pattern.compile(args[offset + 1]);
        }catch(e) {
          throw PatternCompile;
        }
      // should be on count arg
      }else{
        info.count = parseInt('' + args[offset + 1]);
        if(isNaN(info.count)) {
          throw IntegerRange;
        }
      }
      offset+=2;
      arg = args[offset] ? '' + args[offset] : undefined;
    }
  }
}
function validate ( cmd , args , info ) { AbstractCommand . prototype . validate . apply ( this , arguments ) ; var offset = info . exec . offset , arg = args [ offset ] ; if ( args . length > offset + 4 ) { throw new CommandArgLength ( info . exec . definition . name ) ; } // cursor already parsed to integer by numeric validation info . cursor = args [ offset - 1 ] //console.dir(args); if ( arg !== undefined ) { arg = ( ( '' + arg ) . toLowerCase ( ) ) ; while ( arg !== undefined ) { //console.dir(arg); if ( arg !== Constants . SCAN . MATCH && arg !== Constants . SCAN . COUNT ) { throw CommandSyntax ; } else if ( arg === Constants . SCAN . MATCH ) { /* istanbul ignore next: really tough to get a pattern compile error! */ try { info . pattern = Pattern . compile ( args [ offset + 1 ] ) ; } catch ( e ) { throw PatternCompile ; } // should be on count arg } else { info . count = parseInt ( '' + args [ offset + 1 ] ) ; if ( isNaN ( info . count ) ) { throw IntegerRange ; } } offset += 2 ; arg = args [ offset ] ? '' + args [ offset ] : undefined ; } } }
Validate the SCAN command.
Validate the SCAN command .