class ValidReferencesValidator implements ConstraintValidator<ValidReferences, Schema>, ValidationErrorDescriptorBuilder {

    @Override
    public ErrorDescriptor build(ConstraintViolation violation) {
        final List<String> invalidReferences = findInvalidReferences((Schema) violation.getInvalidValue());
        final ErrorDescriptor errorDescriptor = new ErrorDescriptor().setErrorCode(ValidReferences.errorCode)
                .setMessage("Schema contains invalid references: " + invalidReferences.toString());
        for (String invalidReference : invalidReferences) {
            errorDescriptor.addProperties(new ClientProperty().setKey(ValidReferences.PROPERTY_INVALID_REFERENCE)
                    .setValue(invalidReference));
        }
        return errorDescriptor;
    }

}