Migrate entra groupsetting and groupsettingtemplate commands to Zod#7366
Open
waldekmastykarz wants to merge 3 commits into
Open
Migrate entra groupsetting and groupsettingtemplate commands to Zod#7366waldekmastykarz wants to merge 3 commits into
waldekmastykarz wants to merge 3 commits into
Conversation
Migrate all 7 commands to use Zod schemas for option validation: - entra groupsetting add - entra groupsetting get - entra groupsetting list - entra groupsetting remove - entra groupsetting set - entra groupsettingtemplate get - entra groupsettingtemplate list Closes pnp#7297 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Entra groupsetting and groupsettingtemplate command set from legacy option initialization/validation/telemetry patterns to Zod-based schemas, aligning these commands with the newer validation and telemetry flow in the CLI.
Changes:
- Introduces Zod schemas (
schema+ optionalgetRefinedSchema) for option validation across the 7 commands. - Replaces manual GUID validation with
z.uuid()and adds short option aliases via.alias(). - Updates unit tests to validate via
command.getSchemaToParse().safeParse()rather thancommand.validate().
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-list.ts | Adds Zod schema for global-only options and exposes it via schema. |
| src/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-get.ts | Adds strict Zod schema + refined schema enforcing the id/displayName option set. |
| src/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-get.spec.ts | Updates validation tests to use safeParse() against the schema-to-parse. |
| src/m365/entra/commands/groupsetting/groupsetting-set.ts | Migrates to loose Zod schema to support unknown options + GUID validation via z.uuid(). |
| src/m365/entra/commands/groupsetting/groupsetting-set.spec.ts | Updates tests to validate via Zod schema parsing. |
| src/m365/entra/commands/groupsetting/groupsetting-remove.ts | Migrates to strict Zod schema with id and optional force flag. |
| src/m365/entra/commands/groupsetting/groupsetting-remove.spec.ts | Updates validation tests to use schema parsing; removes legacy option-list assertions. |
| src/m365/entra/commands/groupsetting/groupsetting-list.ts | Adds Zod schema for global-only options and exposes it via schema. |
| src/m365/entra/commands/groupsetting/groupsetting-get.ts | Migrates to strict Zod schema for id with UUID validation + alias. |
| src/m365/entra/commands/groupsetting/groupsetting-get.spec.ts | Updates GUID validation tests to use safeParse(). |
| src/m365/entra/commands/groupsetting/groupsetting-add.ts | Migrates to loose Zod schema for templateId + allows unknown options. |
| src/m365/entra/commands/groupsetting/groupsetting-add.spec.ts | Updates GUID validation tests to use safeParse(). |
Address review comments: - Export options const in groupsetting-add.ts and groupsetting-set.ts - Fix spec files to import options from their own command file Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MartinM85
requested changes
Jun 6, 2026
Contributor
MartinM85
left a comment
There was a problem hiding this comment.
Hi @waldekmastykarz , I have a couple of comments, great job otherwise. 👍
Contributor
|
Hi @waldekmastykarz, I don't see any new commit |
Member
Author
|
Something must've gone wrong. Let me check. Thanks for catching it |
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
Migrates all 7
entra groupsettingandentra groupsettingtemplatecommands to use Zod schemas for option validation, replacing the legacy#initOptions(),#initValidators(),#initTelemetry(), and#initOptionSets()patterns.Closes #7297
Commands migrated
entra groupsetting addlooseObjectentra groupsetting getstrictObjectentra groupsetting liststrictObjectentra groupsetting removestrictObjectentra groupsetting setlooseObjectentra groupsettingtemplate getstrictObjectgetRefinedSchemaentra groupsettingtemplate liststrictObjectChanges per command
interface Options extends GlobalOptionswith Zod schema definitionsz.uuid().alias()for short option namesget schema()gettergetRefinedSchema()for option set validation (groupsettingtemplate get)#initOptions(),#initValidators(),#initTelemetry(),#initOptionSets()Test changes
command.validate()tocommandOptionsSchema.safeParse()supports specifyingtests that checkedcommand.optionsarraysettingsNamesstubs no longer needed for option set validation