Effect CommunityEC
Effect Community3y ago
22 replies
revskill

Converting `@effect-ts/schema` Struct to Customized String

Hi everyone, i have a question related to @effect-ts/schema .
I'm parsing the route with path-parser
import { Path } from 'path-parser'
const path = new Path('/users/:id?a&b')
path.test('/users/00123?b=1&a=2')
// {
//  id: "00123",
//. a: "2",
//  b: "1"
// }

Now is there any way to convert a @effect-ts/schema struct into a customized string (like above /users/:id?a&b)
In this case, instead of path = new Path('/users/:id?a&b') , i would just use
const schema = S.struct({
  id: S.string,
  a: S.string,
  b: S.string
})
const strSchema = schemaToString(schema)
const path = new Path(strSchema)
Was this page helpful?