check the padID with a regular expression

This commit is contained in:
Peter 'Pita' Martischka 2011-08-04 16:07:58 +01:00
parent f45b7ce9ea
commit 820c18c7e9
2 changed files with 27 additions and 11 deletions

View file

@ -33,6 +33,9 @@ globalPads = [];
*/
exports.getPad = function(id, callback)
{
if(!exports.isValidPadId(id))
throw new Error(id + " is not a valid padId");
var pad = globalPads[id];
//return pad if its already loaded
@ -69,3 +72,9 @@ exports.doesPadExists = function(padId, callback)
callback(err, value != null);
});
}
exports.isValidPadId = function(padId)
{
return /^([0-9]+\$)?[^$]{1,50}$/.test(padId);
}