Skip to content

Not Blank validator #669

Answered by danielgtaylor
mrguamos asked this question in Q&A
Dec 5, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

@mrguamos you should be able to use the JSON Schema pattern field for this, which works for both params and body fields:

huma.Get(api, "/demo", func(ctx context.Context, input *struct {
	NotBlank string `query:"notblank" pattern:"^\\S+$"`
}) (*Response, error) { /* ... */ })

https://go.dev/play/p/u-XXqr4iF_u

Hope that helps!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mrguamos
Comment options

Answer selected by mrguamos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants