docs: def _do_validate_resourcescenario(resourcescenario, template_id=None):
      """
          Perform a check to ensure a resource scenario's datasets are correct given what the
          definition of that resource (its type) specifies.
      """
      res = resourcescenario.resourceattr.get_resource()
  
      types = res.types
  
      dataset = resourcescenario.dataset
  
      if len(types) == 0:
          return
  
      if template_id is not None:
          if template_id not in [r.templatetype.template_id for r in res.types]:
              raise HydraError("Template %s is not used for resource attribute %s in scenario %s"%\
                               (template_id, resourcescenario.resourceattr.attr.name,
                               resourcescenario.scenario.name))
  
      #Validate against all the types for the resource
      for resourcetype in types:
          #If a specific type has been specified, then only validate
          #against that type and ignore all the others
          if template_id is not None:
              if resourcetype.templatetype.template_id != template_id:
                  continue
          #Identify the template types for the template
          tmpltype = resourcetype.templatetype
          for ta in tmpltype.typeattrs:
              #If we find a template type which mactches the current attribute.
              #we can do some validation.
              if ta.attr_id == resourcescenario.resourceattr.attr_id:
                  if ta.data_restriction:
                      log.debug("Validating against %s", ta.data_restriction)
                      validation_dict = eval(ta.data_restriction)
                      dataset_util.validate_value(validation_dict, dataset.get_val())