'This will step through the script database and make sure
all objects run scripts that are still valid in the context
they are in. This is called by the game engine at regular
intervals but can also be initiated by player scripts.
Only one of the arguments are supposed to be supplied
at a time, since they are exclusive to each other.
Args:
scripts (list, optional): A list of script objects to
validate.
obj (Object, optional): Validate only scripts defined on
this object.
key (str): Validate only scripts with this key.
dbref (int): Validate only the single script with this
particular id.
init_mode (str, optional): This is used during server
upstart and can have three values:
- `None` (no init mode). Called during run.
- `"reset"` - server reboot. Kill non-persistent scripts
- `"reload"` - server reload. Keep non-persistent scripts.
Returns:
nr_started, nr_stopped (tuple): Statistics on how many objects
where started and stopped.
Notes:
This method also makes sure start any scripts it validates
which should be harmless, since already-active scripts have
the property \'is_running\' set and will be skipped.'

def validate(self, scripts=None, obj=None, key=None, dbref=None, init_mode=None):

    global VALIDATE_ITERATION
    if (VALIDATE_ITERATION > 0):
        VALIDATE_ITERATION -= 1
        return (None, None)
    VALIDATE_ITERATION += 1
    nr_started = 0
    nr_stopped = 0
    if init_mode:
        if (init_mode == 'reset'):
            nr_stopped += self.remove_non_persistent(obj=obj)
        scripts = self.get_all_scripts()
        for script in scripts:
            script.is_active = False
    elif (not scripts):
        if (dbref and self.dbref(dbref, reqhash=False)):
            scripts = self.get_id(dbref)
        elif obj:
            scripts = self.get_all_scripts_on_obj(obj, key=key)
        else:
            scripts = self.get_all_scripts(key=key)
    if (not scripts):
        VALIDATE_ITERATION -= 1
        return (None, None)
    for script in scripts:
        if script.is_valid():
            nr_started += script.start(force_restart=init_mode)
        else:
            script.stop()
            nr_stopped += 1
    VALIDATE_ITERATION -= 1
    return (nr_started, nr_stopped)
