arktypea
arktype16mo ago
Möhre

ToJsonSchema fails with narrow

Hi short question, i might be missing something obvious.

If I try to convert a type to jsonschema with a narrow function it fails every time, even if I use the .in property.

const url = type("string")
        .narrow((s, ctx) => {
            if (isValidHttpUrl(s)) {
                return true;
            }

            return ctx.mustBe("a valid URL");
        });

// FAILS:
url.in.toJsonSchema()

// EXPECTED:
{ type: 'string' }
Was this page helpful?