def validate(self, value):
        """
        Applies the validation criteria.
        Returns value, new value, or None if invalid.

        Overload this in derived classes.
        """
        try:
            # trap blank fields here
            if not self.blank or value:
                v = int(value)
                if v < 0:
                    return None
            return value
        except ValueError:
            return None
def validate ( self , value ) : try : if not self . blank or value : v = int ( value ) if v < 0 : return None return value except ValueError : return None
Applies the validation criteria.
        Returns value, new value, or None if invalid.

        Overload this in derived classes.