Search in sources :

Example 1 with FormFieldValidator

use of org.camunda.bpm.engine.impl.form.validator.FormFieldValidator in project camunda-bpm-platform by camunda.

the class ProcessEngineConfigurationImpl method initFormFieldValidators.

protected void initFormFieldValidators() {
    if (formValidators == null) {
        formValidators = new FormValidators();
        formValidators.addValidator("min", MinValidator.class);
        formValidators.addValidator("max", MaxValidator.class);
        formValidators.addValidator("minlength", MinLengthValidator.class);
        formValidators.addValidator("maxlength", MaxLengthValidator.class);
        formValidators.addValidator("required", RequiredValidator.class);
        formValidators.addValidator("readonly", ReadOnlyValidator.class);
    }
    if (customFormFieldValidators != null) {
        for (Entry<String, Class<? extends FormFieldValidator>> validator : customFormFieldValidators.entrySet()) {
            formValidators.addValidator(validator.getKey(), validator.getValue());
        }
    }
}
Also used : FormFieldValidator(org.camunda.bpm.engine.impl.form.validator.FormFieldValidator) FormValidators(org.camunda.bpm.engine.impl.form.validator.FormValidators)

Example 2 with FormFieldValidator

use of org.camunda.bpm.engine.impl.form.validator.FormFieldValidator in project camunda-bpm-platform by camunda.

the class BuiltInValidatorsTest method testDefaultFormFieldValidators.

public void testDefaultFormFieldValidators() {
    // assert default validators are registered
    FormValidators formValidators = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getFormValidators();
    Map<String, Class<? extends FormFieldValidator>> validators = formValidators.getValidators();
    assertEquals(RequiredValidator.class, validators.get("required"));
    assertEquals(ReadOnlyValidator.class, validators.get("readonly"));
    assertEquals(MinValidator.class, validators.get("min"));
    assertEquals(MaxValidator.class, validators.get("max"));
    assertEquals(MaxLengthValidator.class, validators.get("maxlength"));
    assertEquals(MinLengthValidator.class, validators.get("minlength"));
}
Also used : FormFieldValidator(org.camunda.bpm.engine.impl.form.validator.FormFieldValidator) FormValidators(org.camunda.bpm.engine.impl.form.validator.FormValidators)

Example 3 with FormFieldValidator

use of org.camunda.bpm.engine.impl.form.validator.FormFieldValidator in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseValidation.

protected void parseValidation(Element formField, FormFieldHandler formFieldHandler, BpmnParse bpmnParse, ExpressionManager expressionManager) {
    Element validationElement = formField.elementNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "validation");
    if (validationElement != null) {
        List<Element> constraintElements = validationElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "constraint");
        for (Element property : constraintElements) {
            FormFieldValidator validator = Context.getProcessEngineConfiguration().getFormValidators().createValidator(property, bpmnParse, expressionManager);
            String validatorName = property.attribute("name");
            String validatorConfig = property.attribute("config");
            if (validator != null) {
                FormFieldValidationConstraintHandler handler = new FormFieldValidationConstraintHandler();
                handler.setName(validatorName);
                handler.setConfig(validatorConfig);
                handler.setValidator(validator);
                formFieldHandler.getValidationHandlers().add(handler);
            }
        }
    }
}
Also used : FormFieldValidator(org.camunda.bpm.engine.impl.form.validator.FormFieldValidator) Element(org.camunda.bpm.engine.impl.util.xml.Element)

Aggregations

FormFieldValidator (org.camunda.bpm.engine.impl.form.validator.FormFieldValidator)3 FormValidators (org.camunda.bpm.engine.impl.form.validator.FormValidators)2 Element (org.camunda.bpm.engine.impl.util.xml.Element)1