Suppose you have the schema for valid payload defined in accordance to json-schema.org and you'd like to validate it in a proxy prior to handling the payload or passing it to backend, how can you properly validate the contents of the payload?
Apigee doesn't have a JSON schema validator built in, so your best bet is to create a Javascript something like tv4 or another javascript based validator. Then you need to create a Javascript callout which has your script to validate the Apigee flow variable and includes your library (for example, tv4.js)
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="JSO- Validate-JSON">
<DisplayName>JS-Validate-JSON</DisplayName>
<FaultRules/>
<Properties/>
<ResourceURL>jsc://validatejson.js</ResourceURL>
<IncludeURL>jsc://tv4.js</IncludeURL>
</Javascript>
tv4 is available on github at https://github.com/geraintluff/tv4