JDBC Validator

Introduction

The JDBC Validator plugin enhances Joget DX 8 by enabling validation through custom SQL queries. With this plugin, you can validate form data, ensuring accuracy and consistency across your Joget applications.

Get started

Where to get the plugin

You can download the plugin from the GitHub Repository.

How to install

  1. Download the plugin JAR file from the releases page.
  2. Go to Settings > Manage Plugins > Upload Plugin.
  3. Once uploaded, the plugin will be available in your Joget environment.

How to use it

Users can access dynamic parameters to retrieve form field values when crafting the SQL query. Two primary symbols are available for this purpose: the question mark '?' and curly braces '{fieldId}'. These symbols serve distinct functions in data retrieval.

The question mark '?' fetches the current form field's value within the SQL query. It enables users to perform validations based on the data input provided by the user during the form-filling process.

On the other hand, the curly braces '{fieldId}' serve a different purpose. They allow users to access values from other form fields, not necessarily the ones currently being validated. This versatility is valuable in scenarios where cross-field validation is required, enabling comparisons and dependencies between different form elements.

Users can create sophisticated validation rules tailored to their specific business requirements by leveraging these dynamic symbols within their SQL queries. Whether it's simple data checks or complex inter-field relationships, the JDBC Validator provides a flexible and powerful solution to ensure data integrity and compliance within the Joget DX 8 environment.

Understanding JDBC validator 

Assuming you have a Joget DX 8 form that deals with budget entries and you want to validate whether a budget entry with the same year ('c_year') and name ('c_name') already exists while excluding the current budget entry (identified by its 'id'), you can use the following SQL query within the JDBC Validator: 

SELECT * FROM app_fd_budget WHERE c_year = {year} AND c_name = {name} AND id != {id}


Explanation

Combining these conditions ensures that the JDBC Validator checks for duplicate budget entries with the same year and name, excluding the current budget entry being edited (identified by its 'id') from the validation process. 

Configure JDBC validator properties

Fields to configure: 

  • Custom JDBC Driver: This field is required when Custom Datasource is selected in Datasource above.
  • Custom JDBC Password: This field is required when Custom Datasource is selected in Datasource above.
    Test the connection parameters
    Click the Test Connection button at the bottom of the page to test your configurations quickly.
  • Datasource
    • Custom Datasource
    • Default Datasource

    By selecting Default Datasource, the database your Joget is currently using will be selected.

  • Mandatory Fields: A mandatory select box in the JDBC Properties option requires the user to select a value from a predefined set of options, ensuring the proper configuration of essential settings and preventing potential errors caused by invalid inputs.
  • Custom Error Message: Custom Error Message to Show when Validation Fail" input field in the JDBC Validator properties allows you to provide a personalized error message that will be displayed to users when the validation query does not pass. This feature helps improve the clarity and usability of your Joget DX 8 applications by offering more meaningful feedback to users during the form submission process.

Expected outcome

Once configured, you will have SQL validation that ensures data accuracy, such as preventing duplicate budget entries in your forms.

Download plugin

Download sample app

Download the demo app for JDBC Validator:
Created by Julieth Last modified by Aadrian on Nov 19, 2024