Is there any way to declare required variables in BPMN file?
For example, I have a process definition and to start it I have to pass ‘user_id’ variable. If I try to start it without this variable - the process engine should throw an exception and process instance is not created.
otherwise you can configure custom form validator:
@Component
public class CustomValidator implements FormFieldValidator {
public boolean validate(Object submittedValue, FormFieldValidatorContext validatorContext) {
// get access to the current execution
DelegateExecution e = validatorContext.getExecution();
// get access to all form fields submitted in the form submit
Map<String,Object> formVariables = validatorContext.getSubmittedValues();
if(!StringUtils.hasText(formVariables.get("user_id"))){
throw new InvalidRequestException("User_id is null or empty");
}
}
}
Not OP, but this doesn’t seem to work on forms on start events.
In the attached diagram I make a simple form with the validate_me field required.
However I was able to start this flow with an empty body in postman.
It can be seen that there are no process variables, even though validate_me is marked as required.
I could very easily be missing something. Any suggestions would be very much appreciated.