Skip to content

Commit

Permalink
EZP-31954: add missed validation error target (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
ITernovtsii authored Oct 6, 2020
1 parent da365d9 commit bd87be8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/eZ/FieldType/RichText/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected function checkValueStructure(BaseValue $value)
public function validate(FieldDefinition $fieldDefinition, SPIValue $value)
{
return array_map(function ($error) {
return new ValidationError("Validation of XML content failed:\n" . $error);
return new ValidationError("Validation of XML content failed:\n" . $error, null, [], 'xml');
}, $this->inputHandler->validate($value->xml));
}

Expand Down
20 changes: 16 additions & 4 deletions tests/lib/eZ/FieldType/RichTextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ public function providerForTestValidate()
[
new ValidationError(
"Validation of XML content failed:\n" .
'Error in 3:0: Element section has extra content: h1'
'Error in 3:0: Element section has extra content: h1',
null,
[],
'xml'
),
],
],
Expand All @@ -204,7 +207,10 @@ public function providerForTestValidate()
[
new ValidationError(
"Validation of XML content failed:\n" .
"/*[local-name()='section' and namespace-uri()='http://docbook.org/ns/docbook']: The root element must have a version attribute."
"/*[local-name()='section' and namespace-uri()='http://docbook.org/ns/docbook']: The root element must have a version attribute.",
null,
[],
'xml'
),
],
],
Expand All @@ -216,7 +222,10 @@ public function providerForTestValidate()
[
new ValidationError(
"Validation of XML content failed:\n" .
'/section/para/link: using scripts in links is not allowed'
'/section/para/link: using scripts in links is not allowed',
null,
[],
'xml'
),
],
],
Expand All @@ -228,7 +237,10 @@ public function providerForTestValidate()
[
new ValidationError(
"Validation of XML content failed:\n" .
'/section/para/link: using scripts in links is not allowed'
'/section/para/link: using scripts in links is not allowed',
null,
[],
'xml'
),
],
],
Expand Down

0 comments on commit bd87be8

Please sign in to comment.