Validate JSON against Schema
Overview
The Validate JSON against Schema component in Plinqx is designed to ensure the integrity of your data by validating inbound or outbound JSON objects against a predefined JSON schema. This component is essential for maintaining data quality and consistency, especially in complex integration scenarios where adherence to a specific data format is crucial.
Inputs
-
Payload:
The JSON string that you wish to validate.
-
Schema: The JSON schema against which the JSON payload will be validated.
Tip: You can store your schema directly in flows as a plain text template or as a string variable when retrieving it from an SObject.
Outputs
-
Errors:
A collection of strings detailing any errors encountered during the validation process.
-
Success:
A Boolean value indicating the success of the validation. It returns True if the JSON is successfully validated against the schema, or False if it fails the validation.
Example Scenario - Ensuring API Data Compliance
Scenario Overview:
A Salesforce org regularly receives customer data from an external system via API. To ensure the data is in the correct format and contains all required fields, the org needs to validate each JSON payload against a predetermined schema before processing.
Implementation with Validate JSON against Schema Component:
-
Flow Setup for API Data Reception:
- Create a Salesforce flow that is triggered upon the receipt of customer data from the external API.
-
Adding Validate JSON against Schema Component:
- Incorporate the Validate JSON against Schema component early in the flow to validate the incoming JSON payload.
-
Configuring Inputs:
-
'Payload' is set to the incoming JSON string from the API.
-
'Schema' is defined as the JSON schema stored in a plain text template within the flow or retrieved from an SObject.
-
-
Executing JSON Validation:
- The flow processes the incoming JSON payload using the component, validating it against the defined schema.
-
Handling Validation Results:
-
If 'Success' is True, the flow continues to process the validated data.
-
In case of validation failures, the 'Errors' output is used to log the issues and potentially trigger an error handling process or notification.
-
Results:
Implementing the Validate JSON against Schema component allows the Salesforce org to ensure that all incoming customer data via API adheres to the required data structure and format. This proactive validation step enhances data integrity and reduces the risk of errors in downstream processing.