Skip to content

[6.x] Validation improvements & fixes#18944

Merged
brandonkelly merged 7 commits into
6.xfrom
feature/consistent-validatable-preparation
May 22, 2026
Merged

[6.x] Validation improvements & fixes#18944
brandonkelly merged 7 commits into
6.xfrom
feature/consistent-validatable-preparation

Conversation

@riasvdv
Copy link
Copy Markdown
Contributor

@riasvdv riasvdv commented May 21, 2026

Description

Fixes two validation lifecycle gaps:

  • Validatable::prepareForValidation() is now called consistently from Craft ruleset validation, including element rulesets and custom rulesets that override their own preparation hook.

  • Plain Validatable classes using Validates without a configured ruleset now fall back to ComponentRules instead of failing when ruleset resolves to false, so their getRules() contract works as expected.

  • Also fixes an issue with the legacy yii model serializing rulesets.

Also improves the following

  • setAttributes() is now moved from Component to the Validates trait, which makes plain class validation easier
  • ComponentRules has been renamed to ValidatableRules to more clearly describe its intent.

Related issues

@riasvdv riasvdv requested a review from brandonkelly May 21, 2026 18:55
@riasvdv riasvdv marked this pull request as ready for review May 21, 2026 18:55
@riasvdv riasvdv changed the title [6.x] Fix validatable preparation lifecycle [6.x] Validation improvements & fixes May 22, 2026
@brandonkelly brandonkelly merged commit f32020c into 6.x May 22, 2026
18 checks passed
@brandonkelly brandonkelly deleted the feature/consistent-validatable-preparation branch May 22, 2026 17:46
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