Custom FormFieldValidator not working

Hi, how to create a custom validation for a field?

I’m using Springboot and tried this:

package br.com.prt.api.validator;

import org.camunda.bpm.engine.impl.form.validator.FormFieldValidator;
import org.camunda.bpm.engine.impl.form.validator.FormFieldValidatorContext;
import org.springframework.stereotype.Component;

@Component
public class CustomValidator implements FormFieldValidator {

@Override
public boolean validate(Object submittedValue, FormFieldValidatorContext validatorContext) {
System.out.println(submittedValue);
return false;
}

}

Form field in the Modeler:
validator

But my CustomValidator is never called.

Did you find any solution to this ? . I am also facing the same issue.

Hi there,
I would also be interested in an answer to this.
My assumption is, that documentation is simply wrong. I don’t know why
https://docs.camunda.org/manual/7.16/user-guide/task-forms/#form-field-validation
Looking at the implementation, I don’t see a reason why the custom validator shouldn’t behave like a normal validator.

Therefore, I would think the name property should contain the fully qualified name of the validator (instead of the string “validator”) and the config field should contain any arguments you want to pass to the custom validator, just as you pass the min length to the MinLengthValidator

(funny copy&paste naming problem in the code there, by the way)
I’m trying to implement a regEx validator for string values. If my assumption would be wrong, I would have no idea how to pass the actual regEx to the validator if the config value is already occupied by the name of the validator.
However, it seems this feature is not heavily used.
Regards
René

I was wrong. I found the correct lines of code where the check is done

So it’s true, that custom validators can’t have a config.

I will have a look at whether changing the sequence from custom validators first to built-in validators first and then afterwards trying to cast the name of the validator into a class works and make a pull request, if it is working.