How to know the format when programmatically setting a field value I am trying to create a set of entities based on a CSV file on install of a custom module. The entity has a price field and I don't know how to find out what I should be passing in as a value, the following does not work:

$entity = entity_create('item_price', ['type' =&gt; 'wand']);
$entity-&gt;setName('Harry Potter');
$entity-&gt;set('price', 2000);
$entity-&gt;save();


Although this problem is specific to the price field I would like to know as a general rule how does one "discover" what format the value should be in for any field type.
You will need to pass price object to it and not just a number. Do like this -

$price = new Price('2000', 'USD');
$entity-&gt;set('price', $price);
$entity-&gt;save();


You can always look at tests to know how things are working for the module. :)