validates the iso8601 format
    raises value error if the value for fieldname does not match the format
    is iso8601 eg #"2007-06-20T12:34:40+03:00"
4224
def validate_format_iso8601(validator, fieldname, value, format_option):
    
    try:
        iso8601.parse_date(value)
    except ValueError:
        raise ValidationError(
            "Value %(value)r of field '%(fieldname)s' is not in "
            "'iso8601 YYYY-MM-DDThh:mm:ss(+/-)hh:mm' format" % locals())
1369749
def _validate_value(self, value, field_spec, path, errors):
        """"""

        # Check if the value is None and add an error if the field is not nullable.
        # Note that for backward compatibility reasons, the default value of 'nullable'
        # is the inverse of 'required' (which use to mean both that the key be present
        # and not set to None).
        if value is None:
            if not field_spec.get('nullable', not field_spec.get('required', False)):
                errors[path] = "{} is not nullable.".format(path)
            return

        # All fields should have a type
        field_type = field_spec['type']
        if isinstance(field_type, types.FunctionType):
            try:
                field_type = field_type(value)
            except Exception as e:
                raise SchemaFormatException("Dynamic schema function raised exception: {}".format(str(e)), path)
            if not isinstance(field_type, (type, Schema, Array)):
                raise SchemaFormatException("Dynamic schema function did not return a type at path {}", path)


        # If our field is an embedded document, recurse into it
        if isinstance(field_type, Schema):
            if isinstance(value, dict):
                field_type._validate_instance(value, errors, path)
            else:
                errors[path] = "{} should be an embedded document".format(path)
            return

        elif isinstance(field_type, Array):
            if isinstance(value, list):
                is_dynamic = isinstance(field_type.contained_type, types.FunctionType)
                for i, item in enumerate(value):
                    contained_type = field_type.contained_type
                    if is_dynamic:
                        contained_type = contained_type(item)
                    instance_path = self._append_path(path, i)
                    if isinstance(contained_type, Schema):
                        contained_type._validate_instance(item, errors, instance_path)
                    elif not isinstance(item, contained_type):
                        errors[instance_path] = "Array item at {} is of incorrect type".format(instance_path)
                        continue
            else:
                errors[path] = "{} should be an embedded array".format(path)
                return

        elif not isinstance(value, field_type):
            errors[path] = "Field should be of type {}".format(field_type)
            return

        validations = field_spec.get('validates', None)
        if validations is None:
            return
        self._apply_validations(errors, path, validations, value)
309306
def validate(self, value, redis):
        '''
        
        '''
        # cleanup
        if type(value) == str:
            value = value.strip()

        value = self.value_or_default(value)

        # validation
        self.validate_required(value)

        if self.regex and not re.match(self.regex, value, flags=re.ASCII):
            raise InvalidFieldError(self.name)

        if self.forbidden and value in self.forbidden:
            raise ReservedFieldError(self.name)

        if self.allowed and value not in self.allowed:
            raise InvalidFieldError(self.name)

        if self.index:
            key = self.key()

            old = debyte_string(redis.hget(key, value))
            old_value = getattr(self.obj, self.name)

            if old is not None and old != self.obj.id:
                raise NotUniqueFieldError(self.name)
            elif old_value != value:
                self.obj._old[self.name] = old_value

        return value
61997
def validate_format(self, allowed_formats):
        
        if self.format in allowed_formats:
            return

        ui.error("Export type '{0}' does not accept '{1}' format, only: "
                 "{2}".format(self.type, self.format, allowed_formats))
        sys.exit(1)
1326877
function assertValidFieldType(pojoName, fieldName, pojo, expectedType) {
    var value = pojo[fieldName];
    var actualType = typeof value;
    if (value === undefined || value === null) {
        return;
    }
    switch (expectedType) {
        case BOOLEAN_TYPE:
            if (actualType !== BOOLEAN_TYPE && actualType !== NUMBER_TYPE) {
                err();
            }
            pojo[fieldName] = Boolean(value);
            return;
        case NUMBER_TYPE:
            if (actualType === NUMBER_TYPE) {
                return;
            }
            if (actualType === STRING_TYPE) {
                var newValue = parseFloat(value);
                if (isNaN(newValue)) {
                    err();
                }
                pojo[fieldName] = newValue;
            }
            return;
        case STRING_TYPE:
            if (actualType !== STRING_TYPE) {
                pojo[fieldName] = value.toString();
            }
            return;
        case DATE_EXPECTED_TYPE:
            var getTime = value.getTime;
            if (typeof getTime === FUNCTION_TYPE) {
                var timeValue = value.getTime();
                if (isNaN(timeValue)) {
                    err();
                }
                if (!(value instanceof Date)) {
                    pojo[fieldName] = new Date(timeValue);
                }
                return;
            }
            if (actualType === STRING_TYPE) {
                var newDate = new Date(value);
                if (!isNaN(newDate.getTime())) {
                    pojo[fieldName] = newDate;
                    return;
                }
            }
            err();
            return;
        case BUFFER_EXPECTED_TYPE:
            if (!BUFFER_EXISTS) {
                return;
            }
            if (!(value instanceof Buffer)) {
                err();
            }
            return;
    }
    // one pojo of array of array of pojos?
    if (expectedType.length > 3 && expectedType.substr(expectedType.length - 2, 2) === '[]') {
        var individualPojoType = expectedType.substr(0, expectedType.length - 6);
        var asserter_1 = asserters[individualPojoType];
        if (typeof asserter_1 !== FUNCTION_TYPE) {
            err();
        }
        if (isNaN(value.length)) {
            err();
        }
        for (var i = 0; i < value.length; i++) {
            try {
                asserter_1(value[i], true);
            }
            catch (e) {
                err('Error at index \'' + i + '\': ' + e.message);
            }
        }
        // all instances valid
        return;
    }
    var asserter = asserters[expectedType.substr(0, expectedType.length - 4)];
    if (typeof asserter !== FUNCTION_TYPE) {
        expectedTypeErr();
    }
    try {
        asserter(value, true);
    }
    catch (e) {
        err(e.message);
    }
    function err(extraMessage) {
        var message = 'Invalid ' + pojoName + ' provided. Field \'' + fieldName + '\' with value \'' + safeValue(value) + '\' is not a valid \'' + expectedType + '\'.';
        if (extraMessage !== undefined) {
            message += ' ' + extraMessage;
        }
        throw new Error(message);
    }
    function expectedTypeErr() {
        throw new Error('Cannot validate \'' + pojoName + '\' field \'' + fieldName + '\' since expected type provided \'' + expectedType + '\' is not understood.');
    }
}
794420
protected function validateDateFormat($field, $value, $params)
    {
        $parsed = \date_parse_from_format($params[0], $value);

        return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
    }
856889
def validate(self, raw_data, **kwargs):
        
        try:
            converted_data = float(raw_data)
            super(FloatField, self).validate(converted_data, **kwargs)
            return raw_data
        except ValueError:
            raise ValidationException(self.messages['invalid'], repr(raw_data))
1227217
def validate_wrap(self, value):
        ''' '''
        if (not isinstance(value, ObjectId)
                and not isinstance(value, basestring)
                and not isinstance(value, bytes)
            ):
            self._fail_validation_type(value, ObjectId)
        if isinstance(value, ObjectId):
            return
        #: bytes
        if len(value) == 12:
            return
        # hex
        if len(value) != 24:
            self._fail_validation(value, 'hex object ID is the wrong length')
219400
def validate_equal(value):
    
    def equal_validator(field, data):
        if field.value is None:
            return
        if not (field.value == value):
            raise ValidationError('equal', other=value)
    return equal_validator
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)
165444
def validate(self, value):
        """"""
        if value is not None and not isinstance(value, str):
            raise ValidationError("field must be a string")

        super().validate(value)
977439
def validate_field(self, value):
        '''
        
        '''
        if self.choices:
            value = self.normalize_field(value)
            if value in self.choices:
                return None
            return _('Must be one of: %(choices)s') % {'choices': '; '.join(self.choices)}
        if self.default is not None:
            if value is None or value == '':
                value = self.default
        if self.required and (value is None or value == ''):
            return _('Required field')
440099
def assert_valid(self, instance, value=None):
        
        if value is None:
            value = instance._get(self.name)
        if (
                value is not None and
                not self.equal(value, self.validate(instance, value))
        ):
            message = 'Invalid value for property: {}: {}'.format(
                self.name, value
            )
            raise ValidationError(message, 'invalid', self.name, instance)
        return True
323320
def validate_field(field, params)
      begin
        value = params.fetch(field)
        required_error(field) if value.nil? || value.empty?
      rescue KeyError
        required_error(field)
      end
    end
821494
def Validate(self, value, **_):
    """"""
    # None is a valid value - it means the field is not set.
    if value is None:
      return

    # If the value is a string we need to try to convert it to an integer.
    checked_value = value
    if isinstance(value, string_types):
      # NOTE: that when initializing from string, enum values are
      # case-insensitive.
      checked_value = self.enum.get(value.upper())
      if checked_value is None and value.isdigit():
        checked_value = int(value)
      if checked_value is None:
        raise type_info.TypeValueError(
            "Value %s is not a valid enum value for field %s" %
            (value, self.name))

    return EnumNamedValue(checked_value, name=self.reverse_enum.get(value))
978459
def validate_format(self, **kwargs):
        
        args = dict(
            dict_type=self._dict,
            allow_no_value=self._allow_no_value,
            inline_comment_prefixes=self._inline_comment_prefixes,
            strict=self._strict,
            empty_lines_in_values=self._empty_lines_in_values
        )
        args.update(kwargs)
        parser = ConfigParser(**args)
        updated_cfg = str(self)
        parser.read_string(updated_cfg)
421036
def input_has_value(self, field_name, value):
    
    text_field = find_any_field(world.browser,
                                DATE_FIELDS + TEXT_FIELDS,
                                field_name)
    if text_field is False:
        raise AssertionError(
            "Can not find a field named {!r}.".format(field_name))

    actual = text_field.get_attribute('value')
    if actual != value:
        raise AssertionError(
            "Field value expected to be {!r}, got {!r}.".format(
                value, actual))