Skip to content
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

CLI: Parse profile create input using zod #361

Closed
rajdip-b opened this issue Jul 17, 2024 · 4 comments · Fixed by #362
Closed

CLI: Parse profile create input using zod #361

rajdip-b opened this issue Jul 17, 2024 · 4 comments · Fixed by #362
Assignees
Labels
difficulty: 2 foss hack Clustering all the curated issues for Foss Hack 2024 good first issue Good for newcomers priority: medium scope: cli Everything related to the CLI type: enhancement New feature or request

Comments

@rajdip-b
Copy link
Member

Description

private async parseInput(options: CommandActionData['options']): Promise<{
name: string
apiKey: string
baseUrl: string
setDefault: boolean
}> {
let { name, apiKey } = options
const { baseUrl, setDefault } = options
if (!name) {
name = await text({
message: 'Enter the name of the profile',
placeholder: 'work'
})
}
if (!apiKey) {
apiKey = await text({
message: 'Enter the private key for the profile',
placeholder: 'ks_************'
})
}
return { name, apiKey, baseUrl, setDefault }

After we have taken the input from the users, we would like to validate the data using zod.

Validation types

  • name: String containing the charset a-z,A-Z,0-9, and no spaces
  • baseUrl: If not empty, then should be a valid URL
  • apiKey: Should start with ks_ and have characters in a-z,A-Z,0-9
  • setDefault: If specified, should be either true or false.
@rajdip-b rajdip-b added type: enhancement New feature or request good first issue Good for newcomers priority: medium foss hack Clustering all the curated issues for Foss Hack 2024 difficulty: 2 scope: cli Everything related to the CLI labels Jul 17, 2024
@sujal-sakpal
Copy link
Contributor

Hi ,
I’d like to take on the task of integrating input validation with Zod. I’ll define validation schemas for each input field, use zod to ensure the data meets our criteria, and then integrate this into our parseInput function.
Could you please assign this to me?

@rajdip-b
Copy link
Member Author

Sure thing @sujal-sakpal! All the best.

Do not hesitate to ping us in here or in over Discord in case you run into any issues :D

@manasveer6
Copy link

/attempt

Copy link

Assigned the issue to @manasveer6!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 2 foss hack Clustering all the curated issues for Foss Hack 2024 good first issue Good for newcomers priority: medium scope: cli Everything related to the CLI type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants