How to check if object property exists On Craft 3 I am iterating over matrix elements and I need to check if a certain property "videoPoster" exists. It's an asset field, so I actually want to check its length, but I'am already failing to check if it's available...

"ce" is one block of my matrix, this is what I'm doing:

{{ ce.videoPoster is defined ? 'yes' : 'no' }}


Works, gives me a nice "Yes"

Anything else does not work:

{{ ce.videoPoster is defined and ce.videoPoster ? 'yes' : 'no' }}
{{ ce.videoPoster is defined and ce.videoPoster is not null ? 'yes' : 'no' }}
{{ ce.videoPoster is defined and ce.videoPoster | length ? 'yes' : 'no' }}


Exception: Calling unknown method: craft\elements\MatrixBlock::videoPoster()

What is the correct check? I just want to know if I can call ce.videoPost.one()
Just found the trick: When you access an object in array style, you can test via is defined

e.g. 

{{ object['property'] is defined ? 'defined' : 'not defined' }}


and you will get reliable results.