Skip to content

Commit

Permalink
more improvements to schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
bnussman committed Dec 6, 2024
1 parent 406c9c1 commit 67ad321
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/validation/src/nodebalancers.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ export const createNodeBalancerConfigSchema = object({
)
.typeError('Interval must be a number.')
.integer(),
check_passive: boolean(),
check_passive: boolean().when('protocol', {
is: 'udp',
then: (schema) => schema.isFalse(), // You can't enable check_passtive with UDP
}),
check_path: string()
.matches(/\/.*/)
.when('check', {
Expand All @@ -96,7 +99,11 @@ export const createNodeBalancerConfigSchema = object({
is: 'http_body',
then: (schema) => schema.required('An HTTP path is required.'),
}),
proxy_protocol: string().oneOf(['none', 'v1', 'v2']),
proxy_protocol: string().when('protocol', {
is: 'udp',
then: (schema) => schema.oneOf(['none']), // UDP does not support proxy_protocol
otherwise: (schema) => schema.oneOf(['none', 'v1', 'v2']),
}),
check_timeout: number()
.min(
CHECK_TIMEOUT.MIN,
Expand Down

0 comments on commit 67ad321

Please sign in to comment.