Hopefully Mendix adds this feature at some point.
In the meantime, I found this very ugly workaround:
validateAttributeTypes() {
// Get current value and a test value from the list of presets
let trueValue = this.props.targetAttribute.value;
let testValue = this.props.presetAttribute.get(
this.props.presetObject.items[0]
).value
let valid = true;
try {
this.props.targetAttribute.setValue(testValue); // Attempt to set our target attribute to a preset
console.log("Preset and target attribute types are matching");
} catch (e) { // If it fails, it must not be of the right type
alert(`\n${e}\n\nPreset Selector preset and target attributes must be of the same type.`)
valid = false;
}
this.props.targetAttribute.setValue(trueValue); // Set targetAttribute back to the right value
return valid;
}
Essentially, you can try to set the value of the attribute in question and Mendix will either respond with nothing or throw an error telling you that the types aren’t compatible.