How to Cast a String to a Custom Type in Schema

I never remember how to do my own "parsing" in Schema. It may be a transform, but that seeems too complex for the basic thing I want to do. I just want to "cast" a string into a custom type. Something like:
    id: Schema.Trim.pipe(
      Schema.nonEmptyString(),
      Schema.custom(str): str is Mytype => str.startsWith("cid:")))
Was this page helpful?