Search in sources :

Example 1 with CompositeFieldValidator

use of org.apache.tapestry5.internal.services.CompositeFieldValidator in project tapestry-5 by apache.

the class BeanFieldValidatorDefaultSource method createDefaultValidator.

@Override
public FieldValidator createDefaultValidator(final Field field, final String overrideId, final Messages overrideMessages, final Locale locale, final Class propertyType, final AnnotationProvider propertyAnnotations) {
    FieldValidator validator = fieldValidatorDefaultSource.createDefaultValidator(field, overrideId, overrideMessages, locale, propertyType, propertyAnnotations);
    FieldValidator beanValidator = new BeanFieldValidator(field, validatorFactory, beanValidationGroupSource, clientValidatorSource, formSupport, environment);
    return new CompositeFieldValidator(Arrays.asList(validator, beanValidator));
}
Also used : CompositeFieldValidator(org.apache.tapestry5.internal.services.CompositeFieldValidator) FieldValidator(org.apache.tapestry5.FieldValidator) CompositeFieldValidator(org.apache.tapestry5.internal.services.CompositeFieldValidator)

Example 2 with CompositeFieldValidator

use of org.apache.tapestry5.internal.services.CompositeFieldValidator in project tapestry-5 by apache.

the class FieldValidatorDefaultSourceImpl method createDefaultValidator.

public FieldValidator createDefaultValidator(Field field, String overrideId, Messages overrideMessages, Locale locale, Class propertyType, AnnotationProvider propertyAnnotations) {
    List<FieldValidator> validators = newList();
    for (String constraint : validationConstraintGenerator.buildConstraints(propertyType, propertyAnnotations)) {
        int equalsx = constraint.indexOf('=');
        String validatorType = equalsx > 0 ? constraint.substring(0, equalsx) : constraint;
        String constraintValue = equalsx > 0 ? constraint.substring(equalsx + 1) : null;
        FieldValidator validator = fieldValidatorSource.createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, locale);
        validators.add(validator);
    }
    return validators.size() == 1 ? validators.get(0) : new CompositeFieldValidator(validators);
}
Also used : FieldValidator(org.apache.tapestry5.FieldValidator)

Aggregations

FieldValidator (org.apache.tapestry5.FieldValidator)2 CompositeFieldValidator (org.apache.tapestry5.internal.services.CompositeFieldValidator)1