Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Address afterValidation logic to defineRules #11471

Merged
merged 9 commits into from
Jun 23, 2022

Conversation

nfourtythree
Copy link
Contributor

@nfourtythree nfourtythree commented Jun 21, 2022

Description

The move of the logic would allow a developer to hook into the "automatically" added validation and tweak or remove the rules.

With this change a dev could do the following:

Event::on(Address::class, Address::EVENT_DEFINE_RULES, static function($event) {
    foreach ($event->rules as $key => $rule) {
        if (in_array($rule[0], [
            'countryCode',
            'administrativeArea',
            'locality',
            'dependentLocality',
            'postalCode',
            'sortingCode',
            'addressLine1',
            'addressLine2',
        ]) && $rule[1] === 'required') {
            unset($event->rules[$key]);
        }
    }
});

@nfourtythree nfourtythree requested a review from a team as a code owner June 21, 2022 12:05
@nfourtythree nfourtythree self-assigned this Jun 21, 2022
@brandonkelly brandonkelly changed the base branch from develop to 4.1 June 23, 2022 16:19
@brandonkelly brandonkelly merged commit d90b816 into 4.1 Jun 23, 2022
@brandonkelly brandonkelly deleted the feature/move-address-validation-to-rules branch June 23, 2022 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants