Skip to content

Consolidate validation into single source of truth#58

Merged
NducTiOnomBi merged 2 commits into
mainfrom
feature/consolidate-validation
Apr 15, 2026
Merged

Consolidate validation into single source of truth#58
NducTiOnomBi merged 2 commits into
mainfrom
feature/consolidate-validation

Conversation

@NducTiOnomBi

Copy link
Copy Markdown
Owner

Summary

Eliminates duplicate validation logic by refactoring ValidateCharacterData.ps1 to use the module's Test-CharacterData function as the single source of truth.

Changes

Consolidation

  • Tools/ValidateCharacterData.ps1 — Rewritten from ~500 lines to ~210 lines. Now imports VisualEditorFunctions.psm1 and delegates all data validation to Test-CharacterData instead of reimplementing it. Steps reduced from 9 to 5.
  • Eliminates the Cannot validate argument on parameter 'MaximumHistoryCount'. The 0 argument is less than the minimum allowed range of 1. Supply an argument that is greater than or equal to 1 and then try the command again. automatic variable conflict bug

New Validations (in Test-CharacterData)

  • Synergy slot limitcharacters.length + sum(numberMatchesRequired) <= 4 per synergy set
  • skipIfPresentCharacters cross-references — validates referenced character IDs exist
  • Character ID format — enforces ^[A-Z0-9_]+$ pattern

Bug Fixes

  • Tools/StartVisualEditor.ps1 — Fixed single-element array unwrapping on /api/validate and /api/save endpoints (was causing errors.forEach is not a function in editor)
  • Tools/VisualEditorFunctions.psm1ConvertTo-CharacterArray now wraps with @() to prevent single-element unwrapping

Tests

  • Added synergy slot limit test
  • Added JSON array serialization test (prevents regression of the forEach bug)
  • Updated sorting error message regex
  • All 60 Pester tests pass

Validation

  • ValidateCharacterData.ps1 correctly catches MAZKANATA slot limit violation
  • Visual editor displays validation errors properly (no forEach crash)
  • All 60 Pester tests pass (38 visual editor + 22 validation script)

NducTiOnomBi and others added 2 commits April 14, 2026 21:30
- Rewrite ValidateCharacterData.ps1 to use module's Test-CharacterData
  instead of duplicating validation logic (~500 lines to ~210 lines)
- Add synergy slot limit validation to Test-CharacterData
- Add skipIfPresentCharacters cross-reference validation
- Add character ID format validation (uppercase/numbers/underscores)
- Fix single-element array unwrapping in ConvertTo-CharacterArray
- Fix JSON array serialization for single validation errors in editor
- Fix $Error variable conflict (eliminated with duplicate code removal)
- Add test for JSON array serialization of single errors
- All 60 Pester tests pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace hardcoded C:\ paths with cross-platform TestDrive paths
so tests pass on both Windows and ubuntu-latest runners.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@NducTiOnomBi
NducTiOnomBi merged commit c5218fa into main Apr 15, 2026
1 check passed
@NducTiOnomBi
NducTiOnomBi deleted the feature/consolidate-validation branch April 15, 2026 04:34
NducTiOnomBi added a commit that referenced this pull request Apr 15, 2026
Kept unknown property validation and test from this branch
that were removed during merge with main (PR #58 changes).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant