mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 08:28:03 +08:00
refactor: make validateJSONSchema type-safe
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-Claude) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@ -42,7 +42,7 @@ export const toEnvVarInInspect = (envVar: EnvironmentVariable): VarInInspect =>
|
||||
}
|
||||
}
|
||||
|
||||
export const validateJSONSchema = (schema: any, type: string) => {
|
||||
export const validateJSONSchema = (schema: unknown, type: string): z.SafeParseReturnType<unknown, unknown> => {
|
||||
if (type === 'array[string]') {
|
||||
const result = arrayStringSchemaParttern.safeParse(schema)
|
||||
return result
|
||||
@ -60,7 +60,7 @@ export const validateJSONSchema = (schema: any, type: string) => {
|
||||
return result
|
||||
}
|
||||
else {
|
||||
return { success: true } as any
|
||||
return z.unknown().safeParse(schema)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user