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

The union schema of schemas containing a object schema that requires an union schema causes unexpected error. #925

Closed
genki opened this issue Nov 15, 2024 · 1 comment · Fixed by #926
Assignees
Labels
fix A smaller enhancement or bug fix

Comments

@genki
Copy link
Contributor

genki commented Nov 15, 2024

May be I had collided with the edge case.
Extracted the reproduction code.

const ASchema = object({
  foo: union([instance(Uint8Array)]),
  // foo: instance(Uint8Array),  <-- if switched to this, no errors.
});
const BSchema = object({
  bar: array(required(ASchema)),
});
const CSchema = union([BSchema, string()]);
type Data = InferOutput<typeof CSchema>;

const data:Data = {
  bar: [
    {foo: new Uint8Array(32)}
  ],
};

describe("valibot", () => {
  test("data", () => {
    parse(CSchema, data); // throws Error
  });
});
@genki genki changed the title dataset.issues sometimes can be undefined The union schema of schemas containing a object that is required a union schema causes unexpected error. Nov 15, 2024
@genki genki changed the title The union schema of schemas containing a object that is required a union schema causes unexpected error. The union schema of schemas containing a object schema that requires a union schema causes unexpected error. Nov 15, 2024
@genki genki changed the title The union schema of schemas containing a object schema that requires a union schema causes unexpected error. The union schema of schemas containing a object schema that requires an union schema causes unexpected error. Nov 15, 2024
@fabian-hiller fabian-hiller self-assigned this Nov 15, 2024
@fabian-hiller fabian-hiller added the fix A smaller enhancement or bug fix label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A smaller enhancement or bug fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants