Skip to content

flag_constraint which maps the value #100

Description

@ollie-dot-earth

I've used glint quite a bit and I just used a flag constraint for the first time.

I was hoping id be able to do something like this:

use url <- glint.flag(
  glint.string_flag("url")
  |> glint.flag_constraint(fn(url) {
    case uri.parse(url) {
      Error(_) -> snag.error("Invalid url")
      Ok(url) -> Ok(url)
    }
  }),
)

But I don't think this is available at the moment.

It would, however, be quite nice I think. As I currently have to either handle the impossible parse error later on or assert it. Both of which are less than optimal IMO.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions