Skip to content

Commit

Permalink
add repaet validation
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrBarghouthi committed Nov 16, 2018
1 parent 0e97deb commit 0df9ad4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions command.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ class CommandArg {
return res;
}
break;
case ARGUMENT_TYPES.COMMANDS:
this.validator = (str)=>{
let p = new Parser(str);
try{
p.parse()
}catch{
return false;
}
return true;
}
break;
}
} else
this.validator = validator;
Expand Down
2 changes: 1 addition & 1 deletion parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Parser {
constructor(text, afterCmdCallback) {
if (!text) text = '';

this.text = text.trim();
this.text = text.trimRight();
this.index = 0;
this.afterCmdCallback = afterCmdCallback
}
Expand Down

0 comments on commit 0df9ad4

Please sign in to comment.