effect icon indicating copy to clipboard operation
effect copied to clipboard

Schema's TemplateLiteral with NonEmptyString

Open carloschida opened this issue 1 month ago • 0 comments

What is the problem this feature would solve?

Assume we have the following schema

const User = Schema.Struct({
  id: Schema.TemplateLiteral("user_", Schema.String),
})

But what is desirable is instead

const User = Schema.Struct({
  id: Schema.TemplateLiteral("user_", Schema.NonEmptyString),
})

What is the feature you are proposing to solve the problem?

Is there a particular reason why NonEmptyString doesn't work with TemplateLiteral?

Otherwise, this would be an easy task for me to start contributing.

What alternatives have you considered?

A workaround I just thought of, but haven't tried yet, would be:

const User = Schema.Struct({
  id: Schema.TemplateLiteral("user_", Schema.String.pipe(Schema.minLength(1)),
})

carloschida avatar Nov 15 '25 12:11 carloschida