All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lotaris.jee.validation.preprocessing.ValidationPreprocessor Maven / Gradle / Ivy

Go to download

This library offers components that facilitate validation of arbitrary objects and how they are serialized towards a client. It focuses on the wiring of the proposed patterns and does not contain any concrete validator implementations.

There is a newer version: 0.5.2
Show newest version
package com.lotaris.jee.validation.preprocessing;

import com.lotaris.jee.validation.IValidationContext;
import com.lotaris.jee.validation.IValidator;

/**
 * Applies all validators returned by {@link IPreprocessingConfig#getValidators()} to the processed
 * object. If the object is invalid, errors are collected into the {@link ApiErrorResponse}
 * returned by {@link IPreprocessingConfig#getErrors()}.
 *
 * 

Note that the validators are guaranteed to be executed in order.

* * @author Simon Oulevay ([email protected]) */ public class ValidationPreprocessor implements IPreprocessor { @Override @SuppressWarnings("unchecked") public boolean process(Object object, IPreprocessingConfig config) { // build an initial validation context (its current location is the root of the JSON document) final IValidationContext context = config.getValidationContext(); // collect errors for each validator for (IValidator validator : config.getValidators()) { validator.collectErrors(object, context); } return true; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy