How to use RegexConstraint with field?
You do not need to create your own Validator. Instead, use setPropertyConstraints instead of addConstraint to attach the Regex validator to the individual property of the field rather than the FieldItemList. For a string field, add the constraint to &quot;value.&quot; For a link field, you may want to add it to &quot;URI,&quot; etc. Here is an example:
-&gt;setPropertyConstraints(
  'value', ['Regex' =&gt; [
    'pattern' =&gt; '/^[0-9]+$/',
    'message' =&gt; t('Please use numbers only in the blah field.'),
  ]]
);