Skip to content

Commit

Permalink
chore: return early-in-create-cleaner-function
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-abdelqawy committed Dec 3, 2024
1 parent a36c1aa commit e796b2e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,18 +555,19 @@ const _replaceSchemaType = (
}

const createCleaner = (schema: TAnySchema) => (value: unknown) => {
if (typeof value === 'object')
if (typeof value !== 'object') {
return value
}

try {
return Value.Clean(schema, structuredClone(value))
} catch {
try {
return Value.Clean(schema, structuredClone(value))
return Value.Clean(schema, value)
} catch {
try {
return Value.Clean(schema, value)
} catch {
return value
}
return value
}

return value
}
}

export const getSchemaValidator = <T extends TSchema | string | undefined>(
Expand Down

0 comments on commit e796b2e

Please sign in to comment.