class RequestValidator {

	public static <T> void validate(T obj) {
		Set<ConstraintViolation<T>> violations = getInstance().validate(obj);

		if (!violations.isEmpty()) {
			StringBuilder violationStringBuilder = new StringBuilder();
			for (ConstraintViolation<T> violation : violations) {
				violationStringBuilder.append(violation.getPropertyPath().toString())
					.append(" ")
					.append(violation.getMessage())
					.append(System.lineSeparator());
			}
			throw RestUtils.createJsonFormattedException("Malformed " + obj.getClass().getSimpleName() + ": "  + violationStringBuilder.toString(), 400);
		}
	}

}