title: Bean Validation: How can I manually create a ConstraintViolation?
body: <p>I have a specific scenario where I can only check for violation conditions manually, at a later point in the flow. </p>
  
  <p>What I want to do is throw a <code>ConstraintViolationException</code>, and provide a "real" <code>ConstraintViolation object</code> to it (when I catch the exception up the stack, I use the <code>#{validatedValue}</code> and <code>violation.getPropertyPath()</code> parameters).</p>
  
  <p>How can I create a <code>ConstraintViolation</code> myself without having the framework do it for me via annotations (I use Hibernate Validator)?</p>
  
  <p>Code example:</p>
  
  <pre><code>List&lt;String&gt; columnsListForSorting = new ArrayList&lt;String&gt;(service.getColumnsList(domain));
  Collections.sort(columnsListForSorting);
  
  String firstFieldToSortBy = this.getTranslatedFieldName(domain.getClass().getCanonicalName(), sortingInfo.getSortedColumn());
  if (!columnsListForSorting.contains(firstFieldToSortBy)){
      throw new ConstraintViolationException(&lt;what here?...&gt;);
  }
  </code></pre>
  
  <p>Thanks.</p>