Sanitization for number values such as RSSI and CINR

This commit is contained in:
Zaid Abdulla committed 2012-11-01 23:36:15 +03:00
1 parent 52aa4696d7
commit a4b30357e7
2 files changed
+28 -5

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
FLOAT_REGEX = /^([\-\+]?[0-9\.]+)/
extractFloat = (numStr) ->
res = FLOAT_REGEX.exec(numStr)
if res != null
parseFloat(res[1])
else
null
exports.sanitize = (path, value) ->
switch path
when 'InternetGatewayDevice.WiMAX.Status.RSSI'
extractFloat(value)
when 'InternetGatewayDevice.WiMAX.Status.CINR1'
extractFloat(value)
when 'InternetGatewayDevice.WiMAX.Status.CINR2'
extractFloat(value)
else
undefined