Skip to main content
Sometimes you have a data object with properties which shouldn’t always be set, for example in a partial API update where you only want to update certain fields. In this case you can make a property Optional as such:
You can now create the data object as such:
The value of artist will automatically be set to Optional. When you transform this data object to an array, it will look like this:
Optional properties are automatically excluded from the array representation when they are not set.

Manual Optional Values

You can manually use Optional values within magical creation methods as such:

Converting Optional to Null

It is possible to automatically update Optional values to null:
You can read more about this here.