With the release of Fonto 8.14 we’ve introduced a few helper functions that can help you create validator callback functions for your custom endpoints. And with those functions, we’ve also updated our documentation to help you set up your own custom connectors.Â
Creating your own custom connectors was something you could already do in your Fonto Editor instance. However, when using the CmsClient’s sendRequest method, you can supply an option called validateResponse through its options argument. This option’s value should be a callback function which will be used, as the name already implies, validate the response. Until now, this was a function you had to implement yourself.Â
Internally, we already had a few helper functions for implementing the validateResponse callback. With the release of Fonto 8.14, we made these helper functions publicly available for everyone.Â
There are three helper functions which help you create the actual validator callback. There’s one for validating JSON responses, one for validating form data responses, and one for validating blob responses.
Then there are a bunch of smaller helper functions, which help you set up the logic of the validator callback. These functions will, for example, verify that a specific property is present in a JSON response or if the response’s status code is a valid one.
Now that these functions are public API, we’ve updated our AI reference configuration. It uses the createJsonResponseValidator function to set up a response validator for a JSON response. The callback function we pass to that function uses the validateStatus function to validate the response’s status, and it uses validateIsObject and validateNullableProperty to validate the response’s shape.Â
We will gradually update our reference configurations and other code examples to use these helper functions.
Stay up-to-date
Fonto Why & How posts direct in your inbox
Receive updates on new Fonto Why & How blog posts by email
