How to control Optimization.solve() termination smartly

I am using Optimization.jl to train a neural network. I’d like to be able to terminate the convergence based on the behavior of the loss as evaluated on a validation dataset, rather than just setting a limit for number of training iterations. I’m imagining that one might use the callback function for this, evaluating the model on the validation set (which may have to be a global variable to be accessible) and checking whether it’s increasing or decreasing. Has anyone implemented something like this, or are there Optimization tools for this I’m not seeing?