code: def sanitize(self, val):
          
          if self.type == NUMBER:
              try:
                  return clamp(self.min, self.max, float(val))
              except ValueError:
                  return 0.0
          elif self.type == TEXT:
              try:
                  return unicode(str(val), "utf_8", "replace")
              except:
                  return ""
          elif self.type == BOOLEAN:
              if unicode(val).lower() in ("true", "1", "yes"):
                  return True
              else:
                  return False
docs: Given a Variable and a value, cleans it out