fix(shared): update validate() signature to accept undefined#2190
Merged
markscott-ms merged 3 commits intofinos:mainfrom Feb 28, 2026
Merged
Conversation
…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.
Contributor
There was a problem hiding this comment.
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
sharedvalidate()signature to acceptobject | undefinedforarchitectureandpatternOrSchema. - 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.
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? |
Explicitly initialise local variables to undefined and update JSDoc to reflect that validate() parameters are optional.
Member
Author
|
Done @markscott-ms |
markscott-ms
approved these changes
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
validate()insharedto acceptobject | undefinedforarchitectureandpatternOrSchemaparameters, matching the function's existing runtime behaviour (it already handles undefined via truthiness checks)as objecttype assertionsContext
Raised by Copilot review on #2186 — the
as objectcasts in the CLI were bypassing TypeScript's type safety. The root cause was thatvalidate()'s signature declared both parameters as non-nullableobject, even though the function already handlesundefinedinternally.Test plan
npm run buildpassesnpm testpasses across all workspaces (shared change requires full test run)🤖 Generated with Claude Code