in src/internal/BinaryUtils.ts [383:490]
static checkStandardTypeCompatibility(value, typeCode, type = null) {
const valueType = typeof value;
switch (typeCode) {
case BinaryUtils.TYPE_CODE.BYTE:
case BinaryUtils.TYPE_CODE.SHORT:
case BinaryUtils.TYPE_CODE.INTEGER:
case BinaryUtils.TYPE_CODE.LONG:
if (!Number.isInteger(value)) {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.FLOAT:
case BinaryUtils.TYPE_CODE.DOUBLE:
if (valueType !== 'number') {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.CHAR:
if (valueType !== 'string' || value.length !== 1) {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.BOOLEAN:
if (valueType !== 'boolean') {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.STRING:
if (valueType !== 'string') {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.UUID:
if (!(value instanceof Array) ||
value.length !== BinaryUtils.getSize(BinaryUtils.TYPE_CODE.UUID)) {
throw IgniteClientError.valueCastError(value, typeCode);
}
value.forEach(element =>
BinaryUtils.checkStandardTypeCompatibility(element, BinaryUtils.TYPE_CODE.BYTE));
return;
case BinaryUtils.TYPE_CODE.DATE:
if (!(value instanceof Date)) {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.ENUM:
if (!(value instanceof EnumItem)) {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.DECIMAL:
if (!(value instanceof Decimal)) {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.TIMESTAMP:
if (!(value instanceof Timestamp)) {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.TIME:
if (!(value instanceof Date)) {
throw IgniteClientError.valueCastError(value, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.BYTE_ARRAY:
case BinaryUtils.TYPE_CODE.SHORT_ARRAY:
case BinaryUtils.TYPE_CODE.INTEGER_ARRAY:
case BinaryUtils.TYPE_CODE.LONG_ARRAY:
case BinaryUtils.TYPE_CODE.FLOAT_ARRAY:
case BinaryUtils.TYPE_CODE.DOUBLE_ARRAY:
case BinaryUtils.TYPE_CODE.CHAR_ARRAY:
case BinaryUtils.TYPE_CODE.BOOLEAN_ARRAY:
case BinaryUtils.TYPE_CODE.STRING_ARRAY:
case BinaryUtils.TYPE_CODE.UUID_ARRAY:
case BinaryUtils.TYPE_CODE.DATE_ARRAY:
case BinaryUtils.TYPE_CODE.OBJECT_ARRAY:
case BinaryUtils.TYPE_CODE.ENUM_ARRAY:
case BinaryUtils.TYPE_CODE.DECIMAL_ARRAY:
case BinaryUtils.TYPE_CODE.TIMESTAMP_ARRAY:
case BinaryUtils.TYPE_CODE.TIME_ARRAY:
if (!(value instanceof Array)) {
throw IgniteClientError.typeCastError(valueType, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.MAP:
if (!(value instanceof Map)) {
throw IgniteClientError.typeCastError(valueType, typeCode);
}
return;
case BinaryUtils.TYPE_CODE.COLLECTION:
if (!(type && type._isSet() && value instanceof Set || value instanceof Array)) {
throw IgniteClientError.typeCastError(valueType, type && type._isSet() ? 'set' : typeCode);
}
return;
case BinaryUtils.TYPE_CODE.NULL:
if (value !== null) {
throw IgniteClientError.typeCastError('not null', typeCode);
}
return;
default:
const valueTypeCode = BinaryUtils.getTypeCode(BinaryUtils.calcObjectType(value));
if (valueTypeCode === BinaryUtils.TYPE_CODE.BINARY_OBJECT) {
throw IgniteClientError.typeCastError(valueTypeCode, typeCode);
}
return;
}
}