MuleSoft provides the JSON Module specifically for operations such as JSON validation. The application should include the JSON Module as a Mule dependency and place its Validate schema operation before the connector or operation that posts the data to the target system.
The Validate schema operation receives the JSON document and evaluates it against the configured JSON Schema. When validation succeeds, processing continues to the next processor. If the payload does not conform, Mule raises JSON:SCHEMA_NOT_HONOURED, allowing the flow's error-handling strategy to reject or transform the invalid request before the target system is modified.
MuleSoft also documents that modules/connectors added manually to an application are declared in pom.xml as dependencies with the mule-plugin classifier; the JSON Module follows this standard pattern.
DataWeave conditional validation would unnecessarily reimplement schema semantics and would not automatically interpret a JSON Schema. API Manager does not provide the application-level JSON Module operation described by this requirement, and import json-module is not a valid mechanism for invoking the Mule JSON Module from DataWeave.
Reference topics: JSON Module; Validate Schema; JSON Schema; JSON:SCHEMA_NOT_HONOURED; Maven module dependency.
Official documentation: https://docs.mulesoft.com/json-module/latest/json-schema-validation
Official documentation: https://docs.mulesoft.com/json-module/latest/json-xml-maven
===============================================================