post by DavidBinaud on Feb 3, 2022

Hello,

I use CodeIgniter 3 and GroceryCrud Enterprise.
I couldn’t find any information about preformating data before it goes through Valitron.

This is to do some trimming as I would do it before on Community Edition when it used CodeIgniter validation.
Thanks in advance

post by johnny on Feb 5, 2022

Hello @DavidBinaud I guess you are looking for callbackBeforeUpdate | Grocery CRUD - A PHP CRUD Generator Library and callbackBeforeInsert | Grocery CRUD - A PHP CRUD Generator Library functions. You can now also do the validation there and return a custom message, for example (copied from the documentation):

$crud->callbackBeforeInsert(function ($stateParameters) {
    if ($stateParameters->data['status'] === 'Rejected') {
          $errorMessage = new \GroceryCrud\Core\Error\ErrorMessage();
          return $errorMessage->setMessage("You can't add a Rejected status\n");
    }

    return $stateParameters;
});
23 days later

post by DavidBinaud on Feb 28, 2022

Hi, would this allow me to change the data before it goes through Valitron?

i don’t need to validate anything myself, just remove some extra spaces.

1 / 3
Feb 2022