Custom Validations
Types of custom validations
Type | Use |
---|---|
Custom regular expression | Simple formatting checks (i.e. allowing commas and periods as decimal places, supporting multiple currency symbols). |
Validation webhook | Checking data against your database, a third party data source, or writing custom validations in the language of your choice. |
In-memory code-hook | Creating complex, performant custom validations entirely within OneSchema. |
Custom regular expression (regex)
OneSchema supports custom regex in SQL format which can be selected in the data validations list when creating a new template column.
Validation webhook
A validation webhook is a way to use an API endpoint to create a custom validator. OneSchema will pass data to a specified endpoint, and it can be validated against a database, a third party data source, or complex logic checks can be performed. OneSchema simply expects a response of errors and warnings.
Validation webhooks are configured on the template to which they apply. To add a webhook to a template, head to your templates page and click Details on the template you want to edit.
Select Validation webhooks in the left sidebar, followed by Add a new validation hook in the center of the screen.
Then enter a name, endpoint, and select which columns should be passed through. Optionally set a secret key for http basicauth and a bath size.
Then, fill in the relevant fields.
Option | Description |
---|---|
Validation hook name | The name of your webhook. |
URL | The url to the endpoint which will receive the webhook call. |
Template column Keys | The keys of the columns you wish to include with the webhook call. Only selected columns will be sent. |
Secret Key | An optional token used to authenticate the webhook call. |
Batch size | The number of rows of data to include in each call. |
To configure your endpoint on the backend, continue with our guide on validation webhooks.
In-memory code-hook
In-memory code-hooks enable custom validation logic to be written within OneSchema's admin portal without the need to configure a backend webhook endpoint. Some example use cases include merging rows, splitting and merging columns, and multi-column uniqueness checks.
These hooks are extremely performant and reduce implementation complexity when compared to validation webhooks, allowing the entire validation process to be handled by OneSchema.
Note that in-memory code-hooks cannot make external calls, so if you need to validate against your database or a third-party source, you'll need to use a validation webhook.
Updated 6 months ago