code: def uniform_validator(validator):
      
      if not isinstance(validator, dict):
          raise exceptions.ParamsError("invalid validator: {}".format(validator))
  
      if "check" in validator and "expect" in validator:
          # format1
          check_item = validator["check"]
          expect_value = validator["expect"]
          comparator = validator.get("comparator", "eq")
  
      elif len(validator) == 1:
          # format2
          comparator = list(validator.keys())[0]
          compare_values = validator[comparator]
  
          if not isinstance(compare_values, list) or len(compare_values) != 2:
              raise exceptions.ParamsError("invalid validator: {}".format(validator))
  
          check_item, expect_value = compare_values
  
      else:
          raise exceptions.ParamsError("invalid validator: {}".format(validator))
  
      # uniform comparator, e.g. lt => less_than, eq => equals
      comparator = get_uniform_comparator(comparator)
  
      return {
          "check": check_item,
          "expect": expect_value,
          "comparator": comparator
      }
docs: unify validator
  
      Args:
          validator (dict): validator maybe in two formats:
  
              format1: this is kept for compatiblity with the previous versions.
                  {"check": "status_code", "comparator": "eq", "expect": 201}
                  {"check": "$resp_body_success", "comparator": "eq", "expect": True}
              format2: recommended new version, {comparator: [check_item, expected_value]}
                  {'eq': ['status_code', 201]}
                  {'eq': ['$resp_body_success', True]}
  
      Returns
          dict: validator info
  
              {
                  "check": "status_code",
                  "expect": 201,
                  "comparator": "equals"
              }