-
Notifications
You must be signed in to change notification settings - Fork 363
Migrates to Zod v4 #7005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Migrates to Zod v4 #7005
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick review. Nothing major, but maybe I overlooked something.
.strict(); | ||
export const options = z.strictObject({ | ||
...appCommandOptions.shape, | ||
preview: z.boolean().optional().default(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General remark.
If the option is optional, I would expect that the type will be boolean | undefined
, but in that case the return type is simple boolean
. It's a little bit confusing for me.
Is it valid to define option like preview: z.boolean().default(false).optional()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a matter of preference/need, whether we want to distinguish between undefined and false or not. In some case we do, like for set
commands where we want to be able to tell whether to change a property to disabled (false
) or leave it unmodified (undefined
). For other things, we might not care about the undefined state and consider it equal to false
for which we specify a default on the boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add an example how to define flag option? I'm not sure if it's required to set default value to false or keep it only optional
flag: z.boolean().optional()
vs flag: z.boolean().optional().default(false)
. I would prefer flag: z.boolean().optional()
, but global option like the verbose
is defined like flag: z.boolean().optional().default(false)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #7005 (comment)
src/m365/entra/commands/roledefinition/roledefinition-remove.ts
Outdated
Show resolved
Hide resolved
.strict(); | ||
export const options = z.strictObject({ | ||
...globalOptionsZod.shape, | ||
userId: z.string().refine(id => validation.isValidGuid(id), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userId: z.string().refine(id => validation.isValidGuid(id), { | |
userId: z.uuid().refine(id => validation.isValidGuid(id), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're using uuid()
, then we don't need to add manual refinement on top. z.uuid()
would suffice.
Co-authored-by: Martin Machacek <[email protected]>
Co-authored-by: Martin Machacek <[email protected]>
Co-authored-by: Martin Machacek <[email protected]>
Co-authored-by: Martin Machacek <[email protected]>
Co-authored-by: Martin Machacek <[email protected]>
Co-authored-by: Martin Machacek <[email protected]>
Co-authored-by: Martin Machacek <[email protected]>
Thanks for the feedback @MartinM85! Very keen eye! |
No description provided.