docstr: If using rules, validate them
docstr_tok: ["If","using","rules",",","validate","them"]
code: def validate_module(self, pipeline):
      """If using rules, validate them"""
      for flag in self.flags:
          for measurement_setting in flag.measurement_settings:
              if measurement_setting.source_choice == S_RULES:
                  try:
                      rules = self.get_rules(measurement_setting)
                  except Exception as instance:
                      LOGGER.warning(
                          "Failed to load rules: %s",
                          str(instance),
                          exc_info=True,
                      )
                      raise ValidationError(
                          str(instance),
                          measurement_setting.rules_file_name,
                      )
                  if not numpy.all(
                      [r.object_name == IMAGE for r in rules.rules]
                  ):
                      raise ValidationError(
                          "The rules listed in %s describe objects instead of images."
                          % measurement_setting.rules_file_name.value,
                          measurement_setting.rules_file_name,
                      )
                  for r in rules.rules:
                      if (
                          self.rules.Rule.return_fuzzy_measurement_name(
                              pipeline.get_measurement_columns(self),
                              "Image",
                              r.feature,
                              True,
                              measurement_setting.allow_fuzzy,
                          )
                          == ""
                      ):
                          raise ValidationError(
                              "The rule described by %s has not been measured earlier in the pipeline."
                              % r.feature,
                              measurement_setting.rules_file_name,
                          )
              elif measurement_setting.source_choice == S_CLASSIFIER:
                  try:
                      self.get_classifier(measurement_setting)
                      self.get_classifier_features(measurement_setting)
                      self.get_bin_labels(measurement_setting)
                  except IOError:
                      raise ValidationError(
                          "Failed to load classifier file %s"
                          % measurement_setting.rules_file_name.value,
                          measurement_setting.rules_file_name,
                      )
                  except:
                      raise ValidationError(
                          "Unable to load %s as a classifier file"
                          % measurement_setting.rules_file_name.value,
                          measurement_setting.rules_file_name,
                      )
  
imports: import logging
  import os
  import numpy
  from cellprofiler_core.constants.measurement import IMAGE, COLTYPE_INTEGER
  from cellprofiler_core.constants.module import IO_FOLDER_CHOICE_HELP_TEXT
  from cellprofiler_core.constants.workspace import DISPOSITION_CONTINUE, DISPOSITION_SKIP
  from cellprofiler_core.measurement import Measurements
  from cellprofiler_core.module import Module
  from cellprofiler_core.preferences import DEFAULT_INPUT_FOLDER_NAME
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting import Divider
  from cellprofiler_core.setting import HiddenCount
  from cellprofiler_core.setting import Measurement
  from cellprofiler_core.setting import SettingsGroup
  from cellprofiler_core.setting import ValidationError
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.do_something import DoSomething, RemoveSettingButton
  from cellprofiler_core.setting.multichoice import MultiChoice
  from cellprofiler_core.setting.subscriber import LabelSubscriber
  from cellprofiler_core.setting.text import Text, Filename, Directory, Float
  from cellprofiler.utilities.rules import Rules
label_desc: Use image node_id 8 for calling the FlagImage obj's underlying member method code with example usage: obj.validate_module(pipeline) without return types