Resolve #3500997 "Move sdc specific validation"
Closes #3500997
Merge request reports
Activity
assigned to @wimleers
added 1 commit
- 61501eb9 - The current `::validateComponentInput()` is designed to validate *stored*...
- Resolved by Lee Rowlands
- Resolved by Lee Rowlands
added 1 commit
- Resolved by Lee Rowlands
- Resolved by Lee Rowlands
- Resolved by Wim Leers
added 1 commit
- 1a905ea1 - AFAICT one `catch` is unnecessary, because it is caught earlier?
added 1 commit
- b9d621c6 - `::validateComponentInput()` must return validation errors in the server-side data model.
added 1 commit
- a7610a25 - Catch the `SDC`-specific exception and the `DynamicPropSource`-specific...
- Resolved by Wim Leers
- Resolved by Wim Leers
- Resolved by Wim Leers
- Resolved by Wim Leers
- Resolved by Wim Leers
- Resolved by Wim Leers
140 143 $this->assertConvert( 141 144 $invalid_heading_client_json, 142 145 ['model.' . self::TEST_HEADING_UUID . '.style' => 'Does not have a value in the enumeration ["primary","secondary"]'], 143 'The updated title.', 146 // The error above happens in `\Drupal\experience_builder\Controller\ClientServerConversionTrait::convertClientToServer()` 147 // therefore the title, as well as other entity fields will not be updated. 148 'The original title.', 144 149 ); 83 83 'expression' => 'ℹ︎string␟value', 84 84 ], 85 85 ], 86 'component-block' => [], 86 'component-block' => [ 87 'use_site_logo' => TRUE, 88 'use_site_name' => TRUE, 89 'use_site_slogan' => TRUE, 90 'label_display' => FALSE, 91 'label' => '', 92 ], - Comment on lines -86 to +92
This is now fixed throughout the XB codebase: wherever component trees are used, regardless of whether that's a config-defined component tree or not. That's why it was so very important to fix the XB-wide component tree validator to not only validate SDC
-sourcedComponent
s in the tree, but alsoBlock
-sourced ones.
65 65 array_push($test_cases['missing components, using dynamic props'], SchemaIncompleteException::class, 'Schema errors for field.field.node.article.field_xb_test with the following errors: 0 [default_value.0] The 'dynamic' prop source type must be absent., 1 [default_value.0.tree[a548b48d-58a8-4077-aa04-da9405a6f418][0]] The component <em class="placeholder">sdc.sdc_test.missing</em> does not exist., 2 [default_value.0.tree[a548b48d-58a8-4077-aa04-da9405a6f418][1]] The component <em class="placeholder">sdc.sdc_test.missing-also</em> does not exist.'); 66 66 array_push($test_cases['props invalid, using dynamic props'], SchemaIncompleteException::class, 'Schema errors for field.field.node.article.field_xb_test with the following errors: 0 [default_value.0] The 'dynamic' prop source type must be absent.'); 67 67 array_push($test_cases['missing components, using only static props'], SchemaIncompleteException::class, 'Schema errors for field.field.node.article.field_xb_test with the following errors: 0 [default_value.0.tree[a548b48d-58a8-4077-aa04-da9405a6f418][0]] The component <em class="placeholder">sdc.sdc_test.missing</em> does not exist.'); 68 array_push($test_cases['props invalid, using only static props'], SchemaIncompleteException::class, 'Schema errors for field.field.node.article.field_xb_test with the following errors: 0 [default_value.0] The component instance with UUID <em class="placeholder">static-card2df</em> uses component <em class="placeholder">sdc.xb_test_sdc.props-no-slots</em> and receives some invalid props! Put a breakpoint here and figure out why.'); - Resolved by Wim Leers
- Resolved by Wim Leers
FYI: ~150 of the "net new" lines is updating invalid tests to provide the inputs that
Block
-sourcedComponent
s need!That makes this MR seem artificially larger than it is.
It also fixed a number of bugs in HEAD, by making the most important validator that XB have explicit support for
ComponentSource
plugins, rather than hard-coding SDC-style validation.added 2 commits
- Resolved by Wim Leers
589 669 /** 590 670 * {@inheritdoc} 591 671 */ 592 public function clientModelToInput(string $component_instance_uuid, ComponentEntity $component, array $client_model): array { 672 public function clientModelToInput(string $component_instance_uuid, ComponentEntity $component, array $client_model, ConstraintViolationListInterface $violations): array { This only needs to know the UUID in order to form the property path in violations, maybe the caller should do that mapping?
Edited by Dave Long
296 300 /** 297 301 * {@inheritdoc} 298 302 */ 299 public function validateComponentInput(array $inputValues, string $component_instance_uuid, ?FieldableEntityInterface $entity): void { 300 // @todo Implement this in https://drupal.org/i/3500997, which will also allow refactoring ::clientModelToInput() to call this. 303 public function validateComponentInput(array $inputValues, string $component_instance_uuid, ?FieldableEntityInterface $entity): ConstraintViolationListInterface {