Only data type validation is done here
160308
function is_valid_value($value) {
        if(is_array($value)) {
            if(!$this->val_multi) {
                return false;
            }
            else {
                foreach($value as $oneval) {
                    if(!rfc2445_is_valid_value($oneval, $this->val_type)) {
                        return false;
                    }
                }
            }
            return true;
        }
        return rfc2445_is_valid_value($value, $this->val_type);
    }
1317691
def _validate_type(self):  # type: () -> None
        """"""
        if not isinstance(self._value, self._type):
            title = '{} has an invalid type'.format(self._key_name())
            description = '{} must be a {}'.format(self._key_name(), self._type.__name__)

            self._add_error(title=title, description=description)
16048
def check_type(param, datatype):
    
    if param is None:
        return param

    if getattr(datatype, 'clean', None) and callable(datatype.clean):
        try:
            return datatype.clean(param)
        except ValueError:
            raise BadArgumentError(param)

    elif isinstance(datatype, str):
        # You've given it something like `'bool'` as a string.
        # This is the legacy way of doing it.
        datatype = {
            'str': str,
            'bool': bool,
            'float': float,
            'date': datetime.date,
            'datetime': datetime.datetime,
            'timedelta': datetime.timedelta,
            'json': 'json',  # exception
            'int': int,
        }[datatype]

    if datatype is str and not isinstance(param, basestring):
        try:
            param = str(param)
        except ValueError:
            param = str()

    elif datatype is int and not isinstance(param, int):
        try:
            param = int(param)
        except ValueError:
            param = int()

    elif datatype is bool and not isinstance(param, bool):
        param = str(param).lower() in ("true", "t", "1", "y", "yes")

    elif (
        datatype is datetime.datetime and
        not isinstance(param, datetime.datetime)
    ):
        try:
            param = dtutil.string_to_datetime(param)
        except ValueError:
            param = None

    elif datatype is datetime.date and not isinstance(param, datetime.date):
        try:
            param = dtutil.string_to_datetime(param).date()
        except ValueError:
            param = None

    elif (
        datatype is datetime.timedelta and
        not isinstance(param, datetime.timedelta)
    ):
        try:
            param = dtutil.strHoursToTimeDelta(param)
        except ValueError:
            param = None

    elif datatype == "json" and isinstance(param, basestring):
        try:
            param = json.loads(param)
        except ValueError:
            param = None

    return param
1072089
def types_validation!(value)
      raise ValidationError if types && types.none? { |type| type === value }
    end
394
@SuppressWarnings("unchecked")
    public void postValidate(Object object) throws DataValidationException {
        if (_values != null || _ranges != null) {
            if (_values != null) for (Object value: _values) {
                if (value.equals(object)) return;
            }

            if (_ranges != null) for (@SuppressWarnings("rawtypes") Range r: _ranges) {
                @SuppressWarnings("rawtypes")
                Comparable o = (Comparable)object;
                if (r.inclusive) {
                    if ((r.min == null || r.min.compareTo(o) <= 0) && (r.max == null || o.compareTo(r.max) <= 0)) {
                        return;
                    }
                } else {
                    if ((r.min == null || r.min.compareTo(o) < 0) && (r.max == null || o.compareTo(r.max) < 0)) {
                        return;
                    }
                }
            }

            throw new DataValidationException("VALUES/RANGES", _name, object);
        }
    }
1004085
def db_type
      # first, detect any character not number
      case
      when @data.any? { |v| v.to_s =~ DATE_REGEXP }
        'DATE'
      when @data.any? { |v| v.to_s =~ /[^0-9e.-]/ }
        'VARCHAR (255)'
      when @data.any? { |v| v.to_s =~ /\./ }
        'DOUBLE'
      else
        'INTEGER'
      end
    end
994654
def _validated(self, data):
        """"""
        for sub in self.schemas:
            data = sub(data)
        return data
305692
def _validate(data_type, parent_path):
    """"""
    if isinstance(data_type, _CLASS_TYPES):
        raise TypeError(
            "The data type is expected to be an instance object, but got the "
            "type '%s' instead." % (_format_type(data_type),))

    base = _find_base_type(data_type)
    if not base:
        raise TypeError(
            "Objects of type '%s' aren't supported as data types. Use any "
            "type from %s instead."
            % (_format_type(type(data_type)), _join_types(_ALL, "or ")))

    name = getattr(data_type, 'name', None)
    if not name:
        name = type(data_type).__name__

    full_path = '%s.%s' % (parent_path, name) if parent_path else name

    # Generic checks for each attribute.
    for check in _TYPE_ATTR_CHECKS[base]:
        attribute = getattr(data_type, check.name)
        if attribute is None:
            if check.allow_none:
                continue
            else:
                raise TypeError("The attribute '%s.%s' cannot be 'None'."
                                % (full_path, check.name))

        if isinstance(check, _FieldInstanceCheck):
            check_function = isinstance
        elif isinstance(check, _FieldSubclassCheck):
            if not isinstance(attribute, _CLASS_TYPES):
                raise TypeError(
                    "The attribute '%s.%s' is expected to be a type "
                    "object%s." % (full_path, check.name,
                                   " or 'None'" if check.allow_none else ''))

            check_function = issubclass

        if not check_function(attribute, check.type):
            if isinstance(check, _FieldInstanceCheck):
                glue_1 = "an instance object of type"
                glue_2 = "not"
                glue_3 = ""
                type_name = _format_type(type(attribute))
            elif isinstance(check, _FieldSubclassCheck):
                glue_1 = "a subclass of"
                glue_2 = "but got"
                glue_3 = " instead"
                type_name = _format_type(attribute)

            raise TypeError(
                "The attribute '%s.%s' is expected to be %s %s, %s '%s'%s."
                % (full_path, check.name, glue_1,
                   _join_types(check.type, "or "), glue_2, type_name, glue_3))

    # Additional and/or recursive checks for specific attributes.
    if isinstance(data_type, Array):
        _validate(data_type.element_type, full_path)
    elif isinstance(data_type, Structure):
        for field in data_type.fields:
            if not isinstance(field, _SEQUENCE_TYPES):
                raise TypeError(
                    "Each field from the attribute '%s.fields' is expected "
                    "to be an instance object of type %s, not '%s'."
                    % (full_path,
                       _join_types(_SEQUENCE_TYPES + (Field,), "or "),
                       _format_type(type(field))))

            if len(field) not in _FIELD_REQUIRED_ARG_RANGE:
                raise TypeError(
                    "Each field from the attribute '%s.fields' is expected "
                    "to be an instance object of type %s, and compatible with "
                    "the '%s' structure, but got %r instead."
                    % (full_path,
                       _join_types(_SEQUENCE_TYPES + (Field,), "or "),
                       _format_type(Field), field))

            field = Field(*field)
            if not isinstance(field.name, _STRING_TYPES):
                raise TypeError(
                    "The first element of each field from the attribute "
                    "'%s.fields', that is the 'name' attribute, is expected "
                    "to be an instance object of type %s, not '%s'."
                    % (full_path, _join_types(_STRING_TYPES, "or "),
                       _format_type(type(field.name))))

            if not isinstance(field.type, _ALL):
                raise TypeError(
                    "The second element of each field from the attribute "
                    "'%s.fields', that is the 'type' attribute, is expected "
                    "to be an instance object of type %s, not '%s'."
                    % (full_path, _join_types(_ALL, "or "),
                       _format_type(type(field.type))))

            if not isinstance(field.read_only, bool):
                raise TypeError(
                    "The third element of each field from the attribute "
                    "'%s.fields', that is the 'read_only' attribute, is "
                    "expected to be an instance object of type 'bool', "
                    "not '%s'." % (full_path,
                                   _format_type(type(field.read_only))))

            field_path = '%s.%s' % (full_path, field.name)
            _validate(field.type, field_path)

        fields = [field[_FIELD_NAME_IDX] for field in data_type.fields]
        duplicates = _find_duplicates(fields)
        if duplicates:
            if len(duplicates) > 1:
                raise ValueError(
                    "The structure fields %s, were provided multiple times."
                    % (_join_sequence(duplicates, "and ")),)
            else:
                raise ValueError(
                    "The structure field '%s' was provided multiple times."
                    % (duplicates[0]),)

    return True
472333
function validateScalarIsDtype(value, dtype) {
  var inferredDtype = inferDtype(value);
  if (inferredDtype !== null && inferredDtype !== dtype) {
    throw new Error('expected scalar to match dtype "' + dtype +
      '" but instead got ' + value + ', which has dtype "' +
      inferredDtype + '"');
  }
}
996854
private void checkA() throws DatatypeException, IOException {
        if (context.length() == 0) {
            appendToContext(current);
        }
        current = reader.read();
        appendToContext(current);
        skipSpaces();
        boolean expectNumber = true;

        for (;;) {
            switch (current) {
                default:
                    if (expectNumber)
                        reportNonNumber('A', current);
                    return;

                case '+':
                case '-':
                case '.':
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    break;
            }

            checkArg('A', "rx radius");
            skipCommaSpaces();
            checkArg('A', "ry radius");
            skipCommaSpaces();
            checkArg('A', "x-axis-rotation");
            skipCommaSpaces();

            switch (current) {
                default:
                    reportUnexpected("\u201c0\u201d or \u201c1\u201d "
                            + "for large-arc-flag for \u201cA\u201d command",
                            current);
                    skipSubPath();
                    return;
                case '0':
                case '1':
                    break;
            }

            current = reader.read();
            appendToContext(current);
            skipCommaSpaces();

            switch (current) {
                default:
                    reportUnexpected("\u201c0\u201d or \u201c1\u201d "
                            + "for sweep-flag for \u201cA\u201d command",
                            current);
                    skipSubPath();
                    return;
                case '0':
                case '1':
                    break;
            }

            current = reader.read();
            appendToContext(current);
            skipCommaSpaces();

            checkArg('A', "x coordinate");
            skipCommaSpaces();
            checkArg('A', "y coordinate");

            expectNumber = skipCommaSpaces2();
        }
    }
660783
def data_type(self, data_type):
        
        allowed_values = ["string", "number", "date", "color"]
        if data_type is not None and data_type not in allowed_values:
            raise ValueError(
                "Invalid value for `data_type` ({0}), must be one of {1}"
                .format(data_type, allowed_values)
            )

        self._data_type = data_type
969359
def validate(cls, data):
        """"""
        try:
            jsonschema.validate(
                data, cls.SCHEMA,
                # See: https://github.com/Julian/jsonschema/issues/148
                types={'array': (list, tuple)})
        except jsonschema.ValidationError as e:
            raise InvalidFormat("Failure data not of the"
                                " expected format: %s" % (e.message))
        else:
            # Ensure that all 'exc_type_names' originate from one of
            # base exceptions, because those are the root exceptions that
            # python mandates/provides and anything else is invalid...
            causes = collections.deque([data])
            while causes:
                cause = causes.popleft()
                try:
                    generated_on = cause['generated_on']
                    ok_bases = cls.BASE_EXCEPTIONS[generated_on[0]]
                except (KeyError, IndexError):
                    ok_bases = []
                root_exc_type = cause['exc_type_names'][-1]
                if root_exc_type not in ok_bases:
                    raise InvalidFormat(
                        "Failure data 'exc_type_names' must"
                        " have an initial exception type that is one"
                        " of %s types: '%s' is not one of those"
                        " types" % (ok_bases, root_exc_type))
                sub_cause = cause.get('cause')
                if sub_cause is not None:
                    causes.append(sub_cause)
412968
def _validate(self, data: Any, schema: AnyMapping) -> Any:
        
        try:
            return self.validate_func(schema, self._pure_data(data))
        except self.validation_error_class as err:
            logger.error(
                'Schema validation error',
                exc_info=True,
                extra={'schema': schema, 'schema_module': self.module})
            if self.error_class is None:
                raise
            raise self.make_error('Validation Error', error=err) from err
1120271
public void validateFor(final int type) throws ValueFormatException
   {
      if (constraints == null || constraints.length <= 0)
      {
         return;
      }

      if (type == PropertyType.DATE)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  JCRDateFormat.parse(constraint.getMin().getThreshold());
               }

               if (constraint.getMax().getThreshold().length() > 0)
               {
                  JCRDateFormat.parse(constraint.getMax().getThreshold());
               }
            }
            catch (ValueFormatException e)
            {
               throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.DOUBLE)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  Double.parseDouble(constraint.getMin().getThreshold());
               }
               if (constraint.getMax().getThreshold().length() > 0)
               {
                  Double.parseDouble(constraint.getMax().getThreshold());
               }
            }
            catch (NumberFormatException e)
            {
               throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.LONG || type == PropertyType.BINARY)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  Long.parseLong(constraint.getMin().getThreshold());
               }
               if (constraint.getMax().getThreshold().length() > 0)
               {
                  Long.parseLong(constraint.getMax().getThreshold());
               }
            }
            catch (NumberFormatException e)
            {
               throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.BOOLEAN)
      {
         for (String constrString : constraints)
         {
            if (!constrString.equalsIgnoreCase("true") && !constrString.equalsIgnoreCase("false"))
            {
               throw new ValueFormatException("Wrong BOOLEAN constraint format: " + constrString);
            }
         }
      }
   }
1215246
@Override
    public void validate() {
        if (value == null) {
            throw new NoValueGivenException(getPath());
        }

        if (valids.size() != 0) {
            boolean ok = false;
            String valString = (value != null) ? value.toString() : "";

            for (int i = 0; i < valids.size(); i++) {
                if (valids.get(i).equals(valString)) {
                    ok = true;
                    break;
                }
            }

            if (!ok) {
                throw new NoValidValueException(getPath(), valString);
            }
        }

        setValid(true);
    }
1329557
def []=(index, v)
      DataTypeValidator.validate :SimpleTypedList_insert, @allowed_types, v
      raise ArgumentError, "Item is protected and cannot be changed" if protected? index
      @list[index] = v
      v
    end
506933
def name=(v)
      DataTypeValidator.validate :table_name, [String], v
      if v.is_a?(String)
        @name = v
      end
    end