MCPcopy Create free account
hub / github.com/arktypeio/arktype / validated

Function validated

ark/aot/settings.ts:104–122  ·  view source on GitHub ↗
(
	getValidator: unknown,
	data: unknown,
	where: string
)

Source from the content-addressed store, hash-verified

102}
103
104const validated = (
105 getValidator: unknown,
106 data: unknown,
107 where: string
108): PrecompilePluginOptions => {
109 // e.g. { "members": {...} }, an option written beside "precompile"
110 for (const key in data as object) {
111 const option = { [key]: (data as Record<string, unknown>)[key] }
112 if (
113 !("issues" in validators.PrecompileOptions()(option, undefined, null))
114 ) {
115 throw new Error(
116 `${where}${key} must be set in precompile, as in ${JSON.stringify({ precompile: option })}`
117 )
118 }
119 }
120 validate(getValidator as never, data, where)
121 return (data as { precompile?: PrecompilePluginOptions }).precompile ?? {}
122}
123
124// what the call sets over what ark.json does, before any preset
125export const withSettingsFile = <opts extends PrecompilePluginOptions>(

Callers 3

settingsFileOfFunction · 0.85
readSettingsFileFunction · 0.85
diverging.tsFile · 0.85

Calls 1

validateFunction · 0.70

Tested by

no test coverage detected