Skip to content

Coercion: Fix string.url #594

@yamcodes

Description

@yamcodes

This type doesn't work when being put into createEnv:

import { type } from "arkenv";

export default type({
	BUN_PUBLIC_API_URL: "string.url",
	BUN_PUBLIC_DEBUG: "boolean",
});

The existence of the first type throws:

apps/playgrounds/bun-react on  568-coercion-playgroundsexamples [$!] via 🥟 v1.3.2 
❯ nb

> bun-react-playground@0.1.0 build /Users/yamcodes/code/arkenv/apps/playgrounds/bun-react
> NODE_ENV=production bun bin/build.ts

31 |     }
32 | };
33 | export const ToJsonSchema = {
34 |     Error: ToJsonSchemaError,
35 |     throw: (...args) => {
36 |         throw new ToJsonSchema.Error(...args);
                   ^
ToJsonSchemaError: {
    code: "predicate",
    base: {
        type: "string"
    },
    predicate: Function(isParsableUrl)
}
 context: {
  code: "predicate",
  base: [Object ...],
  predicate: [Function: isParsableUrl],
},
    code: "predicate"

      at throw (/Users/yamcodes/code/arkenv/node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/shared/toJsonSchema.js:36:15)
      at reduce (1:11)
      at toResolvedJsonSchema (/Users/yamcodes/code/arkenv/node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/roots/root.js:102:29)
      at reduceObjectJsonSchema (/Users/yamcodes/code/arkenv/node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/structure/structure.js:560:48)
      at reduce (1:11)
      at toResolvedJsonSchema (/Users/yamcodes/code/arkenv/node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/roots/root.js:102:29)
      at toJsonSchema (/Users/yamcodes/code/arkenv/node_modules/.pnpm/@ark+schema@0.56.0/node_modules/@ark/schema/out/roots/root.js:75:36)
      at l (/Users/yamcodes/code/arkenv/packages/arkenv/dist/index.js:1:2188)
      at v (/Users/yamcodes/code/arkenv/packages/arkenv/dist/index.js:4:320)
      at n (/Users/yamcodes/code/arkenv/packages/bun-plugin/dist/index.js:1:89)

Bun v1.3.2 (macOS arm64)
 ELIFECYCLE  Command failed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arkenvChanges to the `arkenv` npm package.bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions