code: def add_validation_fun(phase, keywords, f):
      
      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
docs: 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.