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

fix: validate shouldn't throw #244

Closed
wants to merge 2 commits into from
Closed

Conversation

EvanHahn
Copy link
Contributor

@EvanHahn EvanHahn commented Sep 3, 2024

validate's interface was inconsistent. Sometimes, it would throw an error; sometimes, it would return false. This makes it consistent: always return a boolean.

I discovered this when I noticed that a test wasn't passing the right arguments to validate. When I fixed it, I got test failures.

(You could argue that this should work the other way: it should throw instead of returning a boolean. But that's a bigger breaking change.)

`validate`'s interface was inconsistent. Sometimes, it would `throw` an
error; sometimes, it would return `false`. This makes it consistent:
always return a boolean.

I discovered this when I noticed that a test wasn't passing the right
arguments to `validate`. When I fixed it, I got test failures.

(You could argue that this should work the other way: it should throw
instead of returning a boolean. But that's a bigger breaking change.)
Copy link
Member

@gmaclennan gmaclennan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... I actually think throwing when you pass invalid function parameters (e.g. parameters that do not type-check) is ok behaviour. It's not actually validating anything in this case, so an error is expected. We don't generally do assertions in addition to type checks, but I'm ok with adding adding a more explicit error here like "invalid schema name". I think maybe it's the test that needs updating, with two flows: one for a valid schema name (returns false), and one for an invalid schema name (throws)

@EvanHahn
Copy link
Contributor Author

EvanHahn commented Sep 4, 2024

Closing in favor of #249.

@EvanHahn EvanHahn closed this Sep 4, 2024
@EvanHahn EvanHahn deleted the validate-shouldnt-throw branch September 4, 2024 14:43
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

Successfully merging this pull request may close these issues.

2 participants