def METHOD_NAME(string, field, cutoff=None):
    msg = f'{field} must be a positive integer'
    try:
        value = int(string)
    except ValueError:
        raise exceptions.ValidationError(detail=msg)
    if value < 0:
        raise exceptions.ValidationError(detail=msg)
    if cutoff is not None:
        return min(value, cutoff)
    return value