Skip to content

Have a proper type for URLs we validated #3359

@sodic

Description

@sodic

Version: 0.19
Strongly related: #3361

Wasp uses Zod to validate the URLs users specify through the env vars (frontendUrl, databaseUrl, serverUrl, apiUrl etc.) but it doesn't propagate the confirmed URL validity through the type system. It instead continues treating the URLs as strings.

The problem:

  • Whenever we're dealing with one of these URLs, we have to double-check whether the URL has already been verified.
  • If we forget, we end up with a redundant "Is URL valid" check.
  • Finally, if future versions of Wasp stop validating URLs with Zod, we will have to remember to add checks everywhere.

Branding URLs (i.e., saying they're a URLString instead of string) embeds the information "This URL is confirmed be valid" into the type system and solves these problems. Zod has a brand() option we could probably use.

The task:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions