Skip to content

Commit

Permalink
UI: Fix kafka zod (#1657)
Browse files Browse the repository at this point in the history
- Allows for empty partition field
- Adds some error messaging for the zod schema
  • Loading branch information
Amogh-Bharadwaj authored Apr 30, 2024
1 parent 069a02d commit aad03d4
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions ui/app/peers/create/[peerType]/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,26 +288,42 @@ export const chSchema = z.object({

export const kaSchema = z.object({
servers: z
.array(z.string({ required_error: 'Server address must not be empty' }))
.array(
z.string({
invalid_type_error: 'Invalid server provided',
required_error: 'Server address must not be empty',
})
)
.min(1, { message: 'At least 1 server required' }),
username: z.string().optional(),
password: z.string().optional(),
sasl: z
.union([
z.literal('PLAIN'),
z.literal('SCRAM-SHA-256'),
z.literal('SCRAM-SHA-512'),
])
.union(
[
z.literal('PLAIN'),
z.literal('SCRAM-SHA-256'),
z.literal('SCRAM-SHA-512'),
],
{ errorMap: (issue, ctx) => ({ message: 'Invalid SASL mechanism' }) }
)
.optional(),
partitioner: z
.union([
z.literal('Default'),
z.literal('LeastBackup'),
z.literal('Manual'),
z.literal('RoundRobin'),
z.literal('StickyKey'),
z.literal('Sticky'),
])
.union(
[
z.literal('Default'),
z.literal('LeastBackup'),
z.literal('Manual'),
z.literal('RoundRobin'),
z.literal('StickyKey'),
z.literal('Sticky'),
z.literal(''),
],
{
errorMap: (issue, ctx) => ({
message: 'Invalid partitioning mechanism',
}),
}
)
.optional(),
disableTls: z.boolean().optional(),
});
Expand Down

0 comments on commit aad03d4

Please sign in to comment.