Skip to content
Snippets Groups Projects

feaT: add SequentiallyConstraint and childs and test if we can have our...

Open Björn Brala requested to merge issue/drupal-3521131:3521131-add-support-for into 11.x
6 unresolved threads

feaT: add SequentiallyConstraint and childs and test if we can have our RecursiveContextualValidator just convert values to TypedData if the data is the same.

Closes #3521131

Merge request reports

Members who can merge are allowed to add commits.
Code Quality is loading
Test summary results are being parsed
Metrics reports are loading
Ready to merge by members who can write to the target branch.
  • The source branch is 172 commits behind the target branch.
  • 1 commit will be added to 11.x.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 1 <?php
    2
    3 namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
    4
    5 use Symfony\Component\Validator\Constraint;
    6 use Symfony\Component\Validator\Constraints\SequentiallyValidator;
    7 use Symfony\Component\Validator\Exception\UnexpectedTypeException;
    8
    9 /**
    10 * Validates the Sequentially constraint.
    11 */
    12 class SequentiallyConstraintValidator extends SequentiallyValidator {
  • Stephen Mustgrave left review comments

    left review comments

  • Björn Brala added 1 commit

    added 1 commit

    Compare with previous version

  • quietone
    quietone @quietone started a thread on the diff
  • 1 <?php
    2
    3 namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
    4
    5 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
    6 use Drupal\Core\StringTranslation\TranslatableMarkup;
    7 use Drupal\Core\Validation\Attribute\Constraint;
    8 use Symfony\Component\DependencyInjection\ContainerInterface;
    9 use Symfony\Component\Validator\Constraint as SymfonyConstraint;
    10 use Symfony\Component\Validator\Constraints\Sequentially;
    11
    12 /**
    13 * Checks constraints sequentially and shows the error from the first.
    14 */
    15 #[Constraint(
    16 id: 'Sequentially',
  • quietone
    quietone @quietone started a thread on the diff
  • 2
    3 namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
    4
    5 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
    6 use Drupal\Core\StringTranslation\TranslatableMarkup;
    7 use Drupal\Core\Validation\Attribute\Constraint;
    8 use Symfony\Component\DependencyInjection\ContainerInterface;
    9 use Symfony\Component\Validator\Constraint as SymfonyConstraint;
    10 use Symfony\Component\Validator\Constraints\Sequentially;
    11
    12 /**
    13 * Checks constraints sequentially and shows the error from the first.
    14 */
    15 #[Constraint(
    16 id: 'Sequentially',
    17 label: new TranslatableMarkup('Sequentially validate', [], ['context' => 'Validation'])
    • 'Sequentially validate' is incomplete to me. As in, sequentially validate what?

      Maybe "Validates multiple constraints sequentially" or "Sequentially validate multiple constraints".

    • Please register or sign in to reply
  • quietone
    quietone @quietone started a thread on the diff
  • 55 $violations = $typed_data->validate();
    56
    57 $violationMessages = [];
    58 foreach ($violations as $violation) {
    59 $violationMessages[] = (string) $violation->getMessage();
    60 }
    61
    62 $this->assertEquals($expectedViolations, $violationMessages, 'Validation passed for correct value.');
    63 }
    64
    65 /**
    66 * Data provider for testValidation().
    67 */
    68 public static function dataProvider(): array {
    69 return [
    70 'It should fail on a failing sibling validator' => [
    • Suggested change
      70 'It should fail on a failing sibling validator' => [
      70 'fail on a failing sibling validator' => [

      'It should' isn't adding useful information.

    • Please register or sign in to reply
  • quietone
    quietone @quietone started a thread on the diff
  • 65 /**
    66 * Data provider for testValidation().
    67 */
    68 public static function dataProvider(): array {
    69 return [
    70 'It should fail on a failing sibling validator' => [
    71 'integer',
    72 150,
    73 [
    74 ['Range' => ['min' => 100]],
    75 ['NotNull' => []],
    76 ],
    77 ['This value should be blank.'],
    78 ['Blank' => []],
    79 ],
    80 'it should fail if second validator fails' => [
  • quietone
    quietone @quietone started a thread on the diff
  • 76 ],
    77 ['This value should be blank.'],
    78 ['Blank' => []],
    79 ],
    80 'it should fail if second validator fails' => [
    81 'integer',
    82 250,
    83 [
    84 ['Range' => ['min' => 100]],
    85 ['AllowedValues' => [500]],
    86 ],
    87 [
    88 'The value you selected is not a valid choice.',
    89 ],
    90 ],
    91 'it should show first validation error only even when multiple would fail' => [
    • Suggested change
      91 'it should show first validation error only even when multiple would fail' => [
      91 'show first validation error only even when multiple would fail' => [
    • Please register or sign in to reply
  • quietone left review comments

    left review comments

  • Please register or sign in to reply
    Loading