docs: def validate(self, str_in):
          # type: (Text) -> None
          """ Validates an entry in the field.
  
              Raises `InvalidEntryError` iff the entry is invalid.
  
              An entry is invalid iff (1) a pattern is part of the
              specification of the field and the string does not match
              it; (2) the string does not match the provided casing,
              minimum length, or maximum length; or (3) the specified
              encoding cannot represent the string.
  
              :param str str_in: String to validate.
              :raises InvalidEntryError: When entry is invalid.
              :raises ValueError: When self.case is not one of the
                  permitted values (`'lower'`, `'upper'`, or `'mixed'`).
          """
          if self.is_missing_value(str_in):
              return
          # noinspection PyCompatibility
          super().validate(str_in)  # Validate encoding.
  
          if self.regex_based:
              match = self.regex.match(str_in)
              if match is None:
                  e = InvalidEntryError(
                      'Expected entry that conforms to regular expression '
                      "'{}'. Read '{}'.".format(self.regex.pattern, str_in))
                  e.field_spec = self
                  raise e
  
          else:
              str_len = len(str_in)
              if self.min_length is not None and str_len < self.min_length:
                  e = InvalidEntryError(
                      "Expected string length of at least {}. Read string '{}' "
                      'of length {}.'.format(self.min_length, str_in, str_len))
                  e.field_spec = self
                  raise e
  
              if self.max_length is not None and str_len > self.max_length:
                  e = InvalidEntryError(
                      "Expected string length of at most {}. Read string '{}' "
                      'of length {}.'.format(self.max_length, str_in, str_len))
                  e.field_spec = self
                  raise e
  
              if self.case == 'upper':
                  if str_in.upper() != str_in:
                      msg = "Expected upper case string. Read '{}'.".format(
                          str_in)
                      e = InvalidEntryError(msg)
                      e.field_spec = self
                      raise e
              elif self.case == 'lower':
                  if str_in.lower() != str_in:
                      msg = "Expected lower case string. Read '{}'.".format(
                          str_in)
                      e = InvalidEntryError(msg)
                      e.field_spec = self
                      raise e
              elif self.case == 'mixed':
                  pass
              else:
                  raise ValueError(
                      'Invalid case property {}.'.format(self.case))