'Some patterns causing TypeError in model-json-js
I am trying to use a Json schema to validate a JSON model
I have installed node module model-json-js
One property is using a pattern to try and match the expression. Using 0-9 does not cause any errors.
properties: { test: { type: "string", pattern: "^[0-9]*$" },
but using the same pattern, but [a-z] does cause an error
properties: { test: { type: "string", pattern: "^[a-z]*$" },
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'validate')
at validate (/Users/dave/Documents/Projects/playground/json-model/node_modules/model-json-js/dist/Model.js:1:1942)
I've tried escaping, but cannot find a format that works using letters. What am I doing wrong?
Solution 1:[1]
Sorry, the problem was not in the regex expression, it was in the starting value of the model, not matching the regex expression. The error doesn't get caught in my try/catch, it crashes in the module when the model is being built but at least I don't have to relearn regex to get this working...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | macasas |
