MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / validateOptions

Method validateOptions

packages/server/src/api/rest/index.ts:307–324  ·  view source on GitHub ↗
(options: RestApiHandlerOptions<Schema>)

Source from the content-addressed store, hash-verified

305 }
306
307 private validateOptions(options: RestApiHandlerOptions<Schema>) {
308 const schema = z.strictObject({
309 schema: z.object(),
310 log: loggerSchema.optional(),
311 endpoint: z.string().min(1),
312 pageSize: z.union([z.number().int().positive(), z.literal(Infinity)]).optional(),
313 idDivider: z.string().min(1).optional(),
314 urlSegmentCharset: z.string().min(1).optional(),
315 modelNameMapping: z.record(z.string(), z.string()).optional(),
316 externalIdMapping: z.record(z.string(), z.string()).optional(),
317 queryOptions: queryOptionsSchema.optional(),
318 nestedRoutes: z.boolean().optional(),
319 });
320 const parseResult = schema.safeParse(options);
321 if (!parseResult.success) {
322 throw new Error(`Invalid options: ${fromError(parseResult.error)}`);
323 }
324 }
325
326 get schema() {
327 return this.options.schema;

Callers 1

constructorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected