<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_validation_fun(phase, keywords, f):
 """Add a validation function to some phase in the framework. Function `f` is called for each valid occurance of each keyword in `keywords`. Can be used by plugins to do special validation of extensions."""

    for keyword in keywords:
        if (phase, keyword) in _validation_map:
            oldf = _validation_map[(phase, keyword)]
            def newf(ctx, s):
                oldf(ctx, s)
                f(ctx, s)
            _validation_map[(phase, keyword)] = newf
        else:
            _validation_map[(phase, keyword)] = f