]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(config): tighten Zod validation on uiServer.options.port (#1874) (#1901)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 15 Jun 2026 16:40:57 +0000 (18:40 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Jun 2026 16:40:57 +0000 (18:40 +0200)
commit19afcb2852ccff5e18d11b8522d77f7c5ff80976
tree104c0f5eacfd4d82ec4dbb52fa1a132d7811b9de
parent8fc0b49a0e46c7fd21a4db9cd347326d36547787
fix(config): tighten Zod validation on uiServer.options.port (#1874) (#1901)

* fix(config): tighten Zod validation on uiServer.options.port (#1874)

Replace the permissive z.custom<ListenOptions> bridge under
uiServer.options with a typed object schema validating known primitive
fields, so bad transport-level values (e.g. port: "not-a-number")
fail at boot time in ConfigurationSchema.safeParse instead of later
inside node:net.Server.listen with ERR_SOCKET_BAD_PORT.

The existing accessPolicy refinement is preserved via .pipe(); unknown
keys are still passed through (.loose()) to keep the ListenOptions
extension surface (e.g. signal: AbortSignal) usable.

Validates:
- port: integer in [0, 65535]
- host: non-empty string
- backlog: non-negative integer
- path: non-empty string
- exclusive / ipv6Only / readableAll / writableAll: boolean

Tests: 10 new cases in tests/utils/ConfigurationSchema.test.ts and
1 integration assertion in tests/utils/ConfigurationValidation.test.ts
covering the structured Zod error path uiServer.options.port routed
through ConfigurationValidationError.

* docs(config): align JSDoc with composite uiServer.options schema

Address review comment on #1901: the JSDoc above
UIServerListenOptionsObjectSchema was named after the composite
UIServerListenOptionsSchema, leaving the helper described under the
wrong name and the composite undocumented. UIServerConfigurationSchema
also still referenced the now-removed permissive z.custom<ListenOptions>
bridge.

- UIServerListenOptionsObjectSchema gets its own JSDoc describing the
  typed object layer (.loose() + primitive constraints).
- UIServerListenOptionsSchema gets a JSDoc describing the full chain:
  object guard → accessPolicy refinement → pipe to typed object.
- UIServerConfigurationSchema JSDoc updated to reference the new
  composite schema instead of the obsolete custom bridge.

No behavior change, no test change.
src/utils/ConfigurationSchema.ts
tests/utils/ConfigurationSchema.test.ts
tests/utils/ConfigurationValidation.test.ts