Validate a form in php

Hi,

I try to develop a plugin that contains an action in a form that is coded in the plugins (using onFormProcessed event hook).

During this action, I should set a field of the form required if another field is filled. I would like to know if it is possible to set the field as required but also to mark this field as ‘in error’ to inform the user that he has to fill it.

Thanks.