Luckily for me the key was obsolete, so I removed it to from the Schema.
Then there was no complaints from the API
But No, I did not find a solution.
From my tests, it seems that it is an issue in the Realm Backend Validation Service somewhere.
There is a clash between the Sync Client from mobile and the validation using the Functions.
The issue here is that null in MongoDB is treated as its own distinct type, which is quite different than how most developers would think about a nullable field in statically defined languages. A conversion feature/project is on deck for this quarter so hopefully we will get this sorted for you soon. In the meantime, you can use the workaround Sumedha described: define an empty value, or change the field to be required. Another option is leveraging our new Mixed type here:
Hi,
In relation to this thread, what would be the best recommended way to have a null value in an object relationship?
For instance, I have an object as follows:
public class Template : RealmObject
{
[PrimaryKey]
[MapTo("_id")]
public int TemplateId { get; set; }
public string TemplateDescription { get; set; }
public Department Department { get; set; }
public Example Example{ get; set; }
}
Where Department and Example are Realm objects.
When this is inserted into the realm by my .Net app, the entry in the MongoDB is as follows:
I faced the same issue using Realm Web and after struggle with it I figured it out a 3rd option that has worked for me.
The solution is simply not set the properties which would be null or undefined in the object you are about to persist. If I set them as null or undefined, realm consider this as invalid and throws me the error " Expected: undefined, given: null payerAddress: Invalid type."
Here you can see the null checks that I have to do before setting the properties and its values.