From eedc0f13bcde5310c8a4bf74582254169517f5f6 Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Thu, 26 Mar 2020 13:08:28 -0700 Subject: [PATCH] adds formatting for strings (#2792) --- src/api/telemetry/TelemetryValueFormatter.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/api/telemetry/TelemetryValueFormatter.js b/src/api/telemetry/TelemetryValueFormatter.js index 57ed3d565b..b2af488c04 100644 --- a/src/api/telemetry/TelemetryValueFormatter.js +++ b/src/api/telemetry/TelemetryValueFormatter.js @@ -81,6 +81,24 @@ define([ return printj.sprintf(formatString, baseFormat.call(this, value)); }; } + if (valueMetadata.format === 'string') { + this.formatter.parse = function (value) { + if (value === undefined) { + return ''; + } + if (typeof value === 'string') { + return value; + } else { + return value.toString(); + } + }; + this.formatter.format = function (value) { + return value; + }; + this.formatter.validate = function (value) { + return typeof value === 'string'; + }; + } } TelemetryValueFormatter.prototype.parse = function (datum) {