Remote validation


#1

The idea is to have a validator configurable to call an external webservice to validate data. Squidex offers connectivity after-insertion through rules already, but I don’t see anything available to run custom code (including accessing external dependencies) before insertion.

There is one choice to make with this feature: will the validation only do validation, or can it do data enchancement? (e.g. calculate taxes on an invoice)

I know where to look if we go the validation-only route, adding a validator looks straightforward enough. I believe this new validator could be used for all types, even arrays, what do you think?

The SquareLab team and I are willing to code this feature as it will be useful for our project, we are looking for your guidance and approval. @Sebastian


#2

Hi,

you can implement a custom command handler and make the validation logic before the command is executed:

class MyCommand : ICustomCommandMiddleware
{
     public async Task HandleAsync(CommandContext context, Func<Task> next) 
    {
        if (context.Command is CreateContent createContent)
        {
            // Do your stuff
        }

        await next();
    }
}

I also made a custom example how to write an extension: https://github.com/squidexcontrib/sendgrid

It is far from perfect, because you have to fork the code but it works. Contributions are very welcome.