Problem/Motivation

Ideally, preventing duplicate redirects based on their hashes should be done using validation constraints, instead of form validation. This has two benefits.

  • Prevention will apply in other means of entity creation e.g. via APIs, imports via integrations of CSV files etc.
  • Customization is easier by applications by extending or overriding the validator.

Proposed resolution

Move validation to a constraint plugin.

Issue fork redirect-3525919

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

krystalcode created an issue. See original summary.

krystalcode’s picture

Status: Active » Needs review
StatusFileSize
new7.99 KB

alexpott made their first commit to this issue’s fork.

alexpott’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

@krystalcode this is a really neat idea. +1 for moving validation out of forms and into constraints. I'm going to add some specific test coverage of constraint and check that we have and add if necessary coverage for the form.

I've open an MR and merged this patch to do this.

alexpott’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Added unit test and paired the patch back to the minimum necessary change.

I think this is a nice change that improves redirect validation and the ability to create redirects via an API.

berdir’s picture

Status: Needs review » Needs work

Reviewed.

alexpott’s picture

Status: Needs work » Needs review

I've addressed @berdir's feedback - thanks for the review!

  • berdir committed 22ce0d70 on 8.x-1.x authored by alexpott
    Issue #3525919 by alexpott, krystalcode: Validate hash using entity...
berdir’s picture

Status: Needs review » Fixed

Looks good now, simpler and fewer unrelated changes.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.