Move the validation logic to a constraint validator plugin

Created on 17 March 2023, over 2 years ago

Problem/Motivation

Currently, the validation logic lives on the Giftcard redemption inline form plugin.

I'm working on a decoupled project that will rely on Commerce API for applying Giftcards (See Giftcard integration Needs review ), but instead of "duplicating" the validation logic from the JSON API resource defined, we should, like it is done for coupons, move the validation logic to a GiftcardValidConstraint (i.e a constraint plugin).

The "commerce_giftcards" entity reference field currently has a constraint applied to it: GiftcardOrderCurrency, but I believe it makes more sense to replace this by a constraint plugin that performs all the checks that currently live in the inline form.

The validation should check that the GC has a non zero balance, that its currency matches the order currency and that it can be used for the order store.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇮🇱Israel jsacksick

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024