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: Filter out some Struct errors based on key #2533

Closed
wants to merge 1 commit into from

Conversation

FrederikBolding
Copy link
Member

Filters out some Struct errors in validateUnion by looking at the key. If the key isn't specified in the object we are trying to validate we will assume that that branch of validation errors isn't interesting to the user.

This improves error messages for snap_dialog somewhat as the error message will correctly mention that content is invalid: Invalid params: At path: content — Expected the value to be one of: object, object, but received: ....

This PR does not fix the fact that the error message still doesn't explain what was expected of the union.

@@ -469,7 +469,6 @@ describe('implementation', () => {
);

it.each([
{ type: DialogType.Alert },

This comment was marked as spam.

);
});

it('rejects invalid fields', async () => {

This comment was marked as spam.

@@ -469,7 +469,6 @@ describe('implementation', () => {
);

it.each([
{ type: DialogType.Alert },

This comment was marked as spam.

@@ -487,7 +486,22 @@ describe('implementation', () => {
params: value as any,
}),
).rejects.toThrow(
/Invalid params: At path: .* — Expected a value of type .*, but received: .*\./u,

This comment was marked as spam.

@FrederikBolding FrederikBolding deleted the fb/filter-errors-based-on-key branch July 29, 2024 16:22
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