How to check stats of all saved objects

Hi I am using the saved_objects API to create visualizations and dashboard, but since Kibana does not validate the data as mentioned here:

When you create saved objects, attributes are not validated, which allows you to pass arbitrary and ill-formed data into the API that can break Kibana. Make sure any data that you send to the API is properly formed.

So I want to check some attributes before passing the data to Kibana, such as whether the index-pattern, field names exists and does the type of the field make sense to create visualization. May I know how can I do it?

Thanks!

You'd do this in the app/plugin/whatever you're writing.

Depending on the type of saved object you're creating, there may not be a lot to check against in elasticsearch. If you want to check if a certain saved object exists already (such as an index pattern), you can use the find or get saved object apis.