Problem/Motivation

Validation defined in the FlickrEmbedCode Constraint fails to run with the default config in config/install.

Proposed resolution

Fix validation.

Remaining tasks

Code, review, commit

User interface changes

NA

API changes

NA

Data model changes

NA

CommentFileSizeAuthor
#2 3046832-2.patch3.5 KBfenstrat

Comments

fenstrat created an issue. See original summary.

fenstrat’s picture

Status: Active » Needs review
StatusFileSize
new3.5 KB

Attached patch should fix validation.

Added a Functional test to cover this. It'd be better as a Kernel or even Unit to better test the validator, however as Functional this easily test the config in config/install.

Not uploading a test only patch as there no other tests in the module, so I don't think the tests will actually run anyway (without the fixes it fails locally).

sam152’s picture

I can't see a way that the other code paths in the validator are actually triggered:

if (is_string($value)) {

...

elseif ($value instanceof FieldItemInterface) {

It's attached in getSourceFieldConstraints on the media type plugin, which is then only assigned to the FieldItemList class:

      $source_field_constraints = $media_source->getSourceFieldConstraints();
      $this->get($source_field_name)->getDataDefinition()->setConstraints($source_field_constraints);

Perhaps worth removing the other two types of data? Otherwise, patch looks great.