class InstanceOfValidator implements ConstraintValidator<InstanceOf, ClientExpression>, ValidationErrorDescriptorBuilder {

    @Override
    public ErrorDescriptor build(ConstraintViolation violation) {
        InstanceOf annotation = (InstanceOf) violation.getConstraintDescriptor().getAnnotation();
        final ErrorDescriptor errorDescriptor = new ErrorDescriptor()
                .setErrorCode(annotation.errorCode())
                .setMessage(annotation.message());
        errorDescriptor.addProperties(new ClientProperty("invalidType",
                ClientTypeUtility.extractClientType(violation.getInvalidValue().getClass()))
        );
        return errorDescriptor;
    }

}