Certify that a value is present if required.

    :param object value:
        The value that is to be certified.
    :param bool required:
        Is the value required?
    :raises CertifierValueError:
        Required value is `None`.
333430
def certify_required(value, required=False):
    
    # Certify our kwargs:
    if not isinstance(required, bool):
        raise CertifierParamError(
            'required',
            required,
        )
    if value is None:
        if required:
            raise CertifierValueError(
                message="required value is None",
            )
        return True
355231
def validate(self, value):
        
        try:
            # trap blank fields here
            if not self.blank or value:
                v = int(value)
                if v < self.imin or v > self.imax:
                    return None
            return value
        except ValueError:
            return None
366285
def validate(self, instance, value):                                       #pylint: disable=inconsistent-return-statements
        """"""
        if not isinstance(value, string_types):
            self.error(instance, value)
        for key, val in self.choices.items():
            test_value = value if self.case_sensitive else value.upper()
            test_key = key if self.case_sensitive else key.upper()
            test_val = val if self.case_sensitive else [_.upper() for _ in val]
            if test_value == test_key or test_value in test_val:
                return key
        self.error(instance, value, extra='Not an available choice.')
1227973
def validate(self, value):
        
        if not isinstance(value, dict):
            self.raise_error('Only Python dict may be used in the DictField vs provided {0}'
                             .format(type(value).__name__))
        super(DictField, self).validate(value)
146809
def set_condition(self, value):
        
        if value is None or not isinstance(value, str):
            raise TypeError("Condition is required and must be set to a String")
        else:
            self.__condition = value
829980
def _validate_missing(self, value):
        
        if value is missing_:
            if hasattr(self, 'required') and self.required:
                self.fail('required')
        if value is None:
            if hasattr(self, 'allow_none') and self.allow_none is not True:
                self.fail('null')
972873
def _validate(self, value):
        
        if value is not None:
            raise ValueError('The pk for %s is "auto-increment", you must not fill it' %
                            self._model.__name__)
        key = self._instance.make_key(self._model._name, 'max_pk')
        return self.normalize(self.connection.incr(key))
1057456
def validate(self, value):
        
        super(ChoicesField, self).validate(value)
        if value and not self.valid_value(value):
            self._on_invalid_value(value)
330100
def value_validate(self, value):
        
        if not isinstance(value, six.string_types):
            raise tldap.exceptions.ValidationError("should be a string")
295707
def certify_timestamp(value, required=True):
    
    if certify_required(
        value=value,
        required=required,
    ):
        return

    if not isinstance(value, datetime):
        raise CertifierTypeError(
            message="expected timestamp (datetime), but value is of type {cls!r}".format(
                cls=value.__class__.__name__),
            value=value,
            required=required,
        )
1308863
def validate(self, value):
        
        errors = []
        self._used_validator = []
        for val in self._validators:
            try:
                val.validate(value)
                self._used_validator.append(val)
            except ValidatorException as e:
                errors.append(e)
            except Exception as e:
                errors.append(ValidatorException("Unknown Error", e))
        if len(errors) > 0:
            raise ValidatorException.from_list(errors)
        return value
156054
def _logic(self, value=None):
        # type: (Any) -> Tuple[Union[bool, None], str]
        
        self._validation_result, self._validation_reason = None, 'No reason'
        return self._validation_result, self._validation_reason
52065
def validate(self, value=None, model=None, context=None):
        
        errors = []
        for validator in self.validators:
            if value is None and not isinstance(validator, Required):
                continue

            error = validator.run(
                value=value,
                model=model,
                context=context if self.use_context else None
            )
            if error:
                errors.append(error)

        return errors
325642
def validate(self, value):
        
        try:
            v = int(value)
            if v not in self.allowed:
                return None
            return value
        except ValueError:
            return None
1342984
def validate(self, value):
        
        if value == '':
            if self.kwargs.get('nullable', __nullable__):
                value = None
            else:
                value = 0
            
        if not isinstance(value, Model):
            return super(ReferenceProperty, self).validate(value)

        if not value.is_saved():
            raise BadValueError(
                    '%s instance must be saved before it can be stored as a '
                    'reference' % self.reference_class.__class__.__name__)
        if not isinstance(value, self.reference_class):
            raise KindError('Property %s must be an instance of %s' %
                    (self.name, self.reference_class.__class__.__name__))

        return value
746132
def validate(self, value):
        
        if not isinstance(value, (str, unicode)):
            raise orb.errors.ColumnValidationError(self, 'Invalid password.')

        elif not self.__allowUnicode and value != projex.text.toAscii(value):
            raise orb.errors.ColumnValidationError(self, 'Only ASCII characters are allowed for your password.')

        elif len(value) < self.__minlength or \
                (self.__requireUppercase and not re.search('[A-Z]', value)) or \
                (self.__requireLowercase and not re.search('[a-z]', value)) or \
                (self.__requireNumber and not re.search('[0-9]', value)) or \
                (self.__requireWildcard and not re.search('[^a-zA-Z0-9]', value)):
            raise orb.errors.ColumnValidationError(self, self.rules())

        # check for invalid characters
        elif self.__invalidCharacters and re.search(self.__invalidCharacters, value):
            raise orb.errors.ColumnValidationError(self, self.__invalidCharactersRule)

        else:
            return super(PasswordColumn, self).validate(value)
114112
def validate(self, value):
        
        try:
            # trap blank fields here
            if not self.blank or value:
                float(value)
            return value
        except ValueError:
            return None