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

PathReporter throws when a bigint is part of the error messages #648

Open
jonball4 opened this issue Jun 30, 2022 · 2 comments
Open

PathReporter throws when a bigint is part of the error messages #648

jonball4 opened this issue Jun 30, 2022 · 2 comments

Comments

@jonball4
Copy link

return JSON.stringify(v)

This will throw an error when a bigint is involved. Could we use a replacer in this call to handle bigint?

@gcanti
Copy link
Owner

gcanti commented Aug 4, 2022

@jonball4 could you please provide a repro?

@jonball4
Copy link
Author

@gcanti @jonball4 could you please provide a repro?

    interface PositiveBigIntBrand {
      readonly PositiveBigInt: unique symbol
    }

    const PositiveBigInt = t.brand(
      t.bigint,
      (n): n is t.Branded<bigint, PositiveBigIntBrand> => BigInt(0) < n,
      'PositiveBigInt',
    )

    const testC = t.type({ value: PositiveBigInt });
    const testValidation = testC.decode({ value: -10n });

    // This will throw
    const value = PathReporter.report(testValidation);

jonball4 added a commit to jonball4/io-ts that referenced this issue Nov 2, 2022
jonball4 added a commit to jonball4/io-ts that referenced this issue Nov 2, 2022
jonball4 added a commit to jonball4/io-ts that referenced this issue Nov 2, 2022
jonball4 added a commit to jonball4/io-ts that referenced this issue Nov 2, 2022
jonball4 added a commit to jonball4/io-ts that referenced this issue Nov 8, 2022
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

2 participants