Skip to content

Commit

Permalink
make type more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus committed Oct 3, 2024
1 parent 97eda04 commit 2281c82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions catalog/app/utils/json-schema/json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function makeSchemaValidator(
optSchema?: JsonSchema,
optSchemas?: JsonSchema[],
ajvOptions?: Options,
): (obj?: any) => (Error | ErrorObject)[] {
): (obj?: any) => [Error] | ErrorObject[] {
let mainSchema = R.clone(optSchema || EMPTY_SCHEMA)
if (!mainSchema.$id) {
// Make further code more universal by using one format: `id` → `$id`
Expand Down Expand Up @@ -246,7 +246,7 @@ export function makeSchemaValidator(
// TODO: fail early, return Error instead of callback
if (!$id) return () => [new Error('$id is not provided')]

return (obj: any): (Error | ErrorObject)[] => {
return (obj: any): [Error] | ErrorObject[] => {
try {
ajv.validate($id, R.clone(obj))
} catch (e) {
Expand All @@ -258,7 +258,7 @@ export function makeSchemaValidator(
} catch (e) {
// TODO: fail early if Ajv options are incorrect, return Error instead of callback
// TODO: add custom errors
return () => (e instanceof Error ? [e] : []) as Error[]
return () => (e instanceof Error ? [e] : [])
}
}

Expand Down

0 comments on commit 2281c82

Please sign in to comment.