Skip to content

fix(shared): update validate() signature to accept undefined#2190

Merged
markscott-ms merged 3 commits intofinos:mainfrom
rocketstack-matt:fix/validate-signature-accepts-undefined
Feb 28, 2026
Merged

fix(shared): update validate() signature to accept undefined#2190
markscott-ms merged 3 commits intofinos:mainfrom
rocketstack-matt:fix/validate-signature-accepts-undefined

Conversation

@rocketstack-matt
Copy link
Member

Summary

  • Updates validate() in shared to accept object | undefined for architecture and patternOrSchema parameters, matching the function's existing runtime behaviour (it already handles undefined via truthiness checks)
  • Adds an explicit runtime guard in the CLI caller, replacing unsafe as object type assertions

Context

Raised by Copilot review on #2186 — the as object casts in the CLI were bypassing TypeScript's type safety. The root cause was that validate()'s signature declared both parameters as non-nullable object, even though the function already handles undefined internally.

Test plan

  • npm run build passes
  • npm test passes across all workspaces (shared change requires full test run)
  • No downstream type breakage in CLI or VS Code plugin

🤖 Generated with Claude Code

…ture and pattern

The validate function already handles undefined values at runtime via
truthiness checks, but its signature declared both parameters as
non-nullable. This forced callers to use unsafe `as object` type
assertions. Update the signature to reflect the actual runtime contract
and replace the CLI's type casts with an explicit runtime guard.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the shared validation API typing to reflect existing runtime behavior (handling undefined inputs) and tightens the CLI caller’s runtime validation before invoking shared validation.

Changes:

  • Widen shared validate() signature to accept object | undefined for architecture and patternOrSchema.
  • Add an explicit CLI guard to error early when no validation inputs are provided.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
shared/src/commands/validate/validate.ts Widens validate() parameter types to allow undefined, matching internal truthiness guards.
cli/src/command-helpers/validate.ts Adds a runtime guard to ensure at least one input document is provided before calling validate().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@markscott-ms
Copy link
Contributor

@rocketstack-matt I've merged the strict mode PR #2186 , I assume you want to rebase this branch and address the copilot comments before I look at this?

rocketstack-matt and others added 2 commits February 28, 2026 16:38
Explicitly initialise local variables to undefined and update JSDoc
to reflect that validate() parameters are optional.
@rocketstack-matt
Copy link
Member Author

Done @markscott-ms

@markscott-ms markscott-ms merged commit a284ee0 into finos:main Feb 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants