fuzzyfields/fuzzyfield.py
def postprocess(self, value: Any) -> Any:
        """Post-process the value after validating it and before storing it.
        This method is invoked after :meth:`FuzzyField.validate` and
        tests the ``required`` and ``unique`` flags.

        :raises MissingFieldError:
            if self.required is True and value is None
        :raises DuplicateError:
            if self.unique is True and value is not None and already found
        """
        if value is None:
            if self.required:
                raise MissingFieldError(self.name)
            # Skip uniqueness check
            return self.default

        if self.unique:
            # Exclude the default from the uniqueness check
            if value is None:
                return value

            try:
                if value in self.seen_values:
                    raise DuplicateError(self.name, value)
                hvalue = value
            except TypeError:
                # Unhashable
                hvalue = pickle.dumps(value, protocol=pickle.HIGHEST_PROTOCOL)
                if hvalue in self.seen_values:
                    raise DuplicateError(self.name, value)

            self.seen_values.add(hvalue)

        return value
Post-process the value after validating it and before storing it.
        This method is invoked after :meth:`FuzzyField.validate` and
        tests the ``required`` and ``unique`` flags.

        :raises MissingFieldError:
            if self.required is True and value is None
        :raises DuplicateError:
            if self.unique is True and value is not None and already found
        
Post-process the value after validating it and before storing it.
Post - process the value after validating it and before storing it .
def postprocess(self, value: Any) -> Any:
        if value is None:
            if self.required:
                raise MissingFieldError(self.name)
            return self.default
        if self.unique:
            if value is None:
                return value
            try:
                if value in self.seen_values:
                    raise DuplicateError(self.name, value)
                hvalue = value
            except TypeError:
                hvalue = pickle.dumps(value, protocol=pickle.HIGHEST_PROTOCOL)
                if hvalue in self.seen_values:
                    raise DuplicateError(self.name, value)
            self.seen_values.add(hvalue)
        return value
def postprocess ( self , value : Any ) -> Any : if value is None : if self . required : raise MissingFieldError ( self . name ) return self . default if self . unique : if value is None : return value try : if value in self . seen_values : raise DuplicateError ( self . name , value ) hvalue = value except TypeError : hvalue = pickle . dumps ( value , protocol = pickle . HIGHEST_PROTOCOL ) if hvalue in self . seen_values : raise DuplicateError ( self . name , value ) self . seen_values . add ( hvalue ) return value
Post-process the value after validating it and before storing it.
Post - process the value after validating it and before storing it .
"""Post-process the value after validating it and before storing it.
        This method is invoked after :meth:`FuzzyField.validate` and
        tests the ``required`` and ``unique`` flags.

        :raises MissingFieldError:
            if self.required is True and value is None
        :raises DuplicateError:
            if self.unique is True and value is not None and already found
        """ # Skip uniqueness check # Exclude the default from the uniqueness check # Unhashable
if self.required is True and value is None
if self . required is True and value is None
MissingFieldError
if self.unique is True and value is not None and already found
if self . unique is True and value is not None and already found
DuplicateError
self
value
Any