I think what we want here is 

```python
if (min is not None and value < min) or (max is not None and value > max)
```