1
0
Fork 0
mirror of synced 2024-07-07 07:15:43 +12:00

Quick fix for number systems in string templates.

This commit is contained in:
Michael Drury 2021-01-29 22:56:01 +00:00
parent 41fbc39618
commit af0ef3fc61

View file

@ -110,14 +110,17 @@ module.exports.makePropSafe = property => {
* @returns {boolean} Whether or not the input string is valid. * @returns {boolean} Whether or not the input string is valid.
*/ */
module.exports.isValid = string => { module.exports.isValid = string => {
const specialCases = ["isNumber", "expected a number"]
// don't really need a real context to check if its valid // don't really need a real context to check if its valid
const context = {} const context = {}
try { try {
hbsInstance.compile(processors.preprocess(string, false))(context) hbsInstance.compile(processors.preprocess(string, false))(context)
return true return true
} catch (err) { } 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 // special case for maths functions - don't have inputs yet
return !!(err && err.message.includes("isNumber")) return !!foundCase
} }
} }