From 93a7abf160cedea98b1a770c49d6ced9280c400e Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Fri, 29 Jan 2021 22:56:01 +0000 Subject: [PATCH] Quick fix for number systems in string templates. --- packages/string-templates/src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js index 8c99990ad7..4f0a607965 100644 --- a/packages/string-templates/src/index.js +++ b/packages/string-templates/src/index.js @@ -110,14 +110,17 @@ module.exports.makePropSafe = property => { * @returns {boolean} Whether or not the input string is valid. */ module.exports.isValid = string => { + const specialCases = ["isNumber", "expected a number"] // don't really need a real context to check if its valid const context = {} try { hbsInstance.compile(processors.preprocess(string, false))(context) return true } catch (err) { + const msg = err ? err.message : "" + const foundCase = specialCases.find(spCase => msg.includes(spCase)) // special case for maths functions - don't have inputs yet - return !!(err && err.message.includes("isNumber")) + return !!foundCase } }