Validator custom error message

Hi,
currently I’m creating my own backend module using Flow. The purpose of this module is to manage events. During the creation of a new event, it is necessary to validate the input for the start and end dates to ensure they are correct (with the start date occurring before the end date). To accomplish this, I have created a validator with the following link as help: writing validators.
If the dates are incorrect, an error message should be displayed to inform the user about the issue. The following code snippet is what I used for this:

$this->addError('The start date must be earlier than the end date.', 1622897322);

However, the same error message continues to appear.

Screenshot from 2023-06-06 16-58-22

How can I remove this error message and replace it with my own text?

That messages comes from the errorAction in your controller, that calls addErrorMessage - I will suggest that you override errorAction and have it add your validation messages to the flashmessage container (instead of the `addErrorMessage)

public function errorAction()
{
       foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $propertyPath => $errors) {
            foreach ($errors as $error) {
                $this->controllerContext->getFlashMessageContainer()->addMessage((string) $error);
            }
        }
}

Thank you! Your explanation helped me understand how the messages work. I overrode the getErrorFlashMessage() method and it’s working now. :slightly_smiling_face: