Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

JOI(json validation) js validation supported?

Issue

I was curious if Appsmith supports JOI validation since it is widely used by our clients. Unfortunately, Appsmith does not support JOI out of the box, but a new feature is coming soon that will allow for the importation of JS libs, such as JOI, making validation easier with an external library.

Resolution

The solution to validating JOI in Appsmith is to import JS libs (npm packages) using a new feature that will soon be introduced. This will make it easier to use external libraries for JOI validation.

Here's an example of importing the JOI library in Appsmith:



  1. In the widget where you want to use JOI validation, click on "Edit JS" in the "Custom JS" section.

  2. Add the following code to import the JOI library:


import joi from 'joi';

// example validation
const schema = joi.object({
name: joi.string().alphanum().min(3).max(30).required(),
email: joi.string().email().required(),
age: joi.number().integer().min(18).max(120).required(),
});

const result = schema.validate({
name: 'John Doe',
email: 'johndoe@example.com',
age: 30,
});

console.log(result);



  1. Modify the schema and data as per your validation needs.

  2. Save the widget and you're done!

With this, you can now use JOI validation in your Appsmith app.