-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting Pattern for New Type Structs #1150
Comments
Okay, I am not quite sure what are you after with this? This seems to be quite special case and is not something that is generic for all users of utoipa? |
Basically you should be able to set pattern or regex patterns on new
types. Specifically a new type string
…On Sun, Oct 20, 2024, 10:11 AM Juha Kukkonen ***@***.***> wrote:
Okay, I am not quite sure what are you after with this? This seems to be
quite special case and is not something that is generic for all users of
utoipa?
—
Reply to this email directly, view it on GitHub
<#1150 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACZ5NZ2RUBB433GZE4IFQY3Z4O2YJAVCNFSM6AAAAABQFY3OXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRUHE4DQOBSHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
So for example #[derive(ToSchema)]
#[schema(pattern = r#"^([a-zA-Z0-9_\-]{3,32}$)"#)]
struct Username(String); It would generate the code like the above. P.S I noticed that the way I worded my original issue was confusing. |
Right, now I get it. thanks 🙂 This seems duplicate for this #572. If you find time please go ahead and submit a PR. This should be quite simple to do. It would need the unnamed struct features to parse some of those features currently parsed by named field features. It would be beneficial to add not just pattern, but other useful features as well. |
The ability to apply pattern to new types(Tuple structs with only one data type)
I am willing to add this feature. But I won't be able to look at it til next week.
The text was updated successfully, but these errors were encountered: