Validate a json field from api

Hi, I’ve a controller api that is accepting a json format (patch request) which corresponds to a field (json) in my model.

I know how to validate the json format manually - checking if each key exists and has a value. I also know how to permit only the keys that i’m expecting to get in the api by using strong parameters.

My question is, Is there a way to do the validation automatically? like to have a json template and then get the errors if the input doesn’t match the template?

Thank!

Did you try a custom validator?

Or use StrongParameters: