I create a validator (this is called from attached() of my view-model/widget and I assign it to the model (the page model) and ensure there is a value of the string value that is at least one and less than 26 characters. Then I add a reporter and subscribe to it.
Ok so this works. The issue is, on edit in memory this model gets a
_ validationReporter _ (two underscores) assigned only on change. ie. if I open this panel with the model, the validation reporter is not there. But if I edit it in some way this _ validationReporter _ object is added.
When I process my form to submit it to the server (a REST API) I call
JSON.stringify(model);
This caused the following stack
core-framework.js:5 ERROR [stamp-editor] TypeError: Converting circular structure to JSON
at Object.stringify (native)
I tracked this down to this _ validationReporter _ on the model. If I simply delete it, the stringify works. So I can work around this, but this seems a bit unintuitive. ie. by adding validation we are adding a private object which is creating circular references which is potentially impacting serialization.
So I switched over to the validatejs in place of the validation Aurelia library.
I added some validation rules to one of my models. The code is very straight forward:
` setupValidation() {
`
I create a validator (this is called from attached() of my view-model/widget and I assign it to the model (the page model) and ensure there is a value of the string value that is at least one and less than 26 characters. Then I add a reporter and subscribe to it.
Ok so this works. The issue is, on edit in memory this model gets a
_ validationReporter _ (two underscores) assigned only on change. ie. if I open this panel with the model, the validation reporter is not there. But if I edit it in some way this _ validationReporter _ object is added.
When I process my form to submit it to the server (a REST API) I call
This caused the following stack
core-framework.js:5 ERROR [stamp-editor] TypeError: Converting circular structure to JSON at Object.stringify (native)
I tracked this down to this _ validationReporter _ on the model. If I simply delete it, the stringify works. So I can work around this, but this seems a bit unintuitive. ie. by adding validation we are adding a private object which is creating circular references which is potentially impacting serialization.