file name constraint in form I've got a basic field constraint figured out (per question here: Validation constraints on form fields ignored )

Next, I want to constrain the main image field to limit the file name. For example, if someone uploads a file named "1234-shutterstock.jpg" I want to detect that the file name contains "shutterstock" and add that violation. 

But I have no clue how to tackle the syntax for this. Maybe someone can point me in the right direction?

I've started with something like this. I know this is wrong.

            &lt;?php   
            namespace Drupal\custom_validation\Plugin\Validation\Constraint;

            use Symfony\Component\Validator\Constraint;
            use Symfony\Component\Validator\ConstraintValidator;

            /**
             * Validates the Image constraint.
             */
            class MainImageConstraintValidator extends ConstraintValidator {

              /**
               * {@inheritdoc}
               */
              public function validate($items, Constraint $constraint) {
                foreach ($items as $item) {   
                  if (strpos($item-&gt;value, 'shutterstock') !== false) {
                    $this-&gt;context-&gt;addViolation($constraint-&gt;wrongImageName, ['%value' =&gt; $item-&gt;value]);
                  }

                }
              }

            }
Per Clive's comment above, it works with this:   

        namespace Drupal\custom_validation\Plugin\Validation\Constraint;

        use Symfony\Component\Validator\Constraint;
        use Symfony\Component\Validator\ConstraintValidator;

        /**
         * Validates the Image constraint.
         */
        class MainImageConstraintValidator extends ConstraintValidator {

          /**
           * {@inheritdoc}
           */
          public function validate($items, Constraint $constraint) {
            foreach ($items as $item) {   
              if (strpos($item-&gt;entity-&gt;filename-&gt;value, 'shutterstock') !== false) {
                $this-&gt;context-&gt;addViolation($constraint-&gt;wrongImageName, ['%value' =&gt; $item-&gt;value]);
              }

            }
          }

        }