Skip to content

refactor(validation): move per-type validation into series plugins#641

Merged
korvin89 merged 2 commits into
mainfrom
feat/move-validation-to-plugins
Jun 22, 2026
Merged

refactor(validation): move per-type validation into series plugins#641
korvin89 merged 2 commits into
mainfrom
feat/move-validation-to-plugins

Conversation

@korvin89

@korvin89 korvin89 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI generated

Description

validateData had a switch over the series type, so adding a new type meant
editing a central file. Type-specific validation now lives in the type's own
plugin, keeping the change local. Part of the ongoing pluginization effort.

What changed

  • SeriesPlugin: optional validate?(args) method + ValidateSeriesArgs type.
    Core loops over series and delegates via getSeriesPlugin(type).validate?.(...).
  • The registry is now the source of truth for available types: hasSeriesPlugin /
    getRegisteredSeriesTypes replace the hardcoded SERIES_TYPE list in validation.
  • Shared XY helpers extracted into core/validation/helpers.ts.
  • validate() added to area, bar-x, bar-y, line, scatter, pie, treemap.
    Single-consumer logic (pie value check, treemap structure check) lives in its
    own plugin rather than in shared helpers.
  • Removed validateSeries / countSeriesByType / validateStackingAreaNullMode.
  • The validation test registers plugins (import '../../../plugins') so the
    registry is populated.

Behavior

Unchanged — same error codes and messages. The only difference is that the type
list in the invalid-series-type message now follows plugin registration order.

Remove the per-type switch from validateData and delegate type-specific
checks to an optional validate() on each series plugin (CHARTS-12940).

- Add validate?(args) + ValidateSeriesArgs to the SeriesPlugin interface
- Add hasSeriesPlugin/getRegisteredSeriesTypes so the registry is the
  source of truth for available types (drops the SERIES_TYPE hardcode)
- Extract shared XY helpers into core/validation/helpers.ts
- Add validate() to area, bar-x, bar-y, line, scatter, pie, treemap;
  pie/treemap checks live in their own plugins
- Register plugins in the validation test so getSeriesPlugin resolves

Error codes and messages are preserved.
@korvin89 korvin89 requested a review from kuzmadom as a code owner June 19, 2026 18:19
@gravity-ui

gravity-ui Bot commented Jun 19, 2026

Copy link
Copy Markdown

📖 Docs Preview is ready.

@gravity-ui-bot

Copy link
Copy Markdown
Contributor

Preview is ready.

@gravity-ui

gravity-ui Bot commented Jun 19, 2026

Copy link
Copy Markdown

Visual Tests Report is ready.
Performance Tests Report is ready.

Comment thread src/core/validation/helpers.ts Outdated
Drop the concrete-series union (XYSeries) and per-type params from the
shared validation helpers; type them by the shape they actually read so
core no longer enumerates specific series types.
@korvin89 korvin89 merged commit 99c1863 into main Jun 22, 2026
10 checks passed
@korvin89 korvin89 deleted the feat/move-validation-to-plugins branch June 22, 2026 09:00
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.

3 participants