Skip to content

Schema's TemplateLiteral with NonEmptyString #5751

@carloschida

Description

@carloschida

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)),
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions