Skip to content

Zod schema and option set #6325

Answered by waldekmastykarz
MartinM85 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, there is. We use schema refinements for this. Check out

public getRefinedSchema(schema: typeof options): z.ZodEffects<any> | undefined {
return schema
.refine(options => typeof options.appId !== 'undefined' || cli.getConfig().get(settingsNames.clientId), {
message: `appId is required. TIP: use the "m365 setup" command to configure the default appId`
})
.refine(options => options.authType !== 'password' || options.userName, {
message: 'Username is required when using password authentication',
path: ['userName']
})
.refine(options => options.authType !== 'passw…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@waldekmastykarz
Comment options

Answer selected by MartinM85
@MartinM85
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants