Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused variables in error construction logic #33

Open
johtso opened this issue Mar 6, 2023 · 0 comments
Open

Unused variables in error construction logic #33

johtso opened this issue Mar 6, 2023 · 0 comments

Comments

@johtso
Copy link

johtso commented Mar 6, 2023

Unless I'm missing something, the value and prop variables here are unused:

for (let issue of result.error.issues) {
const { message, path, code, expected, received } = issue
const [key, index] = path
let value = o[key]
let prop = key
if (index !== undefined) {
value = value[index]
prop = `${key}[${index}]`
}
addError(key, message)
}
return { success: false, data: undefined, errors }

Also more generally, I'm not really clear on why the errors are being manipulated.

Would it not make more sense to just return the raw output of safeParse and allow the user to use something like result.error.flatten()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant