public FormFieldValidator createValidator ( Element constraint , BpmnParse bpmnParse , ExpressionManager expressionManager ) { String name = constraint . attribute ( "name" ) ; String config = constraint . attribute ( "config" ) ; if ( "validator" . equals ( name ) ) { // custom validators if ( config == null || config . isEmpty ( ) ) { bpmnParse . addError ( "validator configuration needs to provide either a fully " + "qualified classname or an expression resolving to a custom FormFieldValidator implementation." , constraint ) ; } else { if ( StringUtil . isExpression ( config ) ) { // expression Expression validatorExpression = expressionManager . createExpression ( config ) ; return new DelegateFormFieldValidator ( validatorExpression ) ; } else { // classname return new DelegateFormFieldValidator ( config ) ; } } } else { // built-in validators Class < ? extends FormFieldValidator > validator = validators . get ( name ) ; if ( validator != null ) { FormFieldValidator validatorInstance = createValidatorInstance ( validator ) ; return validatorInstance ; } else { bpmnParse . addError ( "Cannot find validator implementation for name '" + name + "'." , constraint ) ; } } return null ; }
factory method for creating validator instances