How can I validate meta-boxes inside my Gutenberg plugin
I am trying to run a validation routine on my WordPress plugin which I am developing with Gutenberg.
My plugin is to store Book information having the following fields, which are meta-boxes.
The meta-boxes and posts are saving fine, but I want to implement some validations on these fields before the data is actually passed to
REST API, and the best place for this to happen is when user hits
Update button. Meaning before sending the value the plugin would run the validation routine.
For this I want to write a Higher Order Component, where I would put the validation rules and return True / False based on the value passed.
I am thinking the skeleton like this: My Gutenberg Block wrapped inside a Higher Order Component.
But the problem is when I hit Publish or Update, the REST API is called internally and I have no control (yet) to prevent this from happening before running my validation routine.
I have searched a lot but nowhere I could see a proper example or anything close to it which addresses my concern.
It would be extremely helpful if somebody please suggest the right approach or directs me towards any tutorial focusing this.
I added another question here on Sept 20 but unfortunately I received no reply there yet!