I'm willing to writing a feature where you can provide either an integer or a function for max and duration.
It could work like the "id" field where ctx is available.
max: Integer|function
duration: Integer|function
Would you be open to this feature?