A custom metadata type has a Field Definition related to an Entity. The following validation rule ensures the value of this field can only be a User lookup:
AND(
FieldDefinition__c != NULL,
FieldDefinition__r.DataType != 'Lookup(User)')
When trying to create a record with Field Definition set to a User lookup field the validation rule causes an error - incorrectly.
However, the following Apex block passes - correctly:
Custom__mdt m = [SELECT FieldDefinition__r.DataType FROM Custom__mdt WHERE Id = 'm003h0000011eBi'];
System.assertEquals(false,
m.FieldDefinition__c != null &&
m.FieldDefinition__r.DataType != 'Lookup(User)');
Is this yet another bug with custom metadata types?