Sanitization for number values such as RSSI and CINR
This commit is contained in:
1 parent
52aa4696d7
commit
a4b30357e7
2 files changed
+28
-5
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user