I'm defining a base field for my custom content entity:
$fields['machine_name'] = BaseFieldDefinition::create('string') ->setLabel(t('Machine name')) ->addConstraint('UniqueField') ->addConstraint('Regex', ['pattern' => '[^a-z0-9_]+']) ->setTranslatable(false) ->setRequired(true);
However RegexValidator throws
UnexpectedTypeException complaining that passed value is of type
FieldItemList. This is obvious since in Drupal 8 even single value fields are lists (with one item).
So how can I use Regex validator with entity fields? Or do I have to write my own regex validator that will handle