Skip to content
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

[REQ][rust-server] Regex pattern validation for strings #10546

Open
Foorack opened this issue Oct 6, 2021 · 3 comments
Open

[REQ][rust-server] Regex pattern validation for strings #10546

Foorack opened this issue Oct 6, 2021 · 3 comments

Comments

@Foorack
Copy link
Contributor

Foorack commented Oct 6, 2021

Is your feature request related to a problem? Please describe.

Taking the following object as example:

    UserID:
      type: string
      title: UserID
      pattern: '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}'

The server then allows invalid user ID's which are not compliant with the defined pattern.

@matthewjchou
Copy link

matthewjchou commented Dec 9, 2021

Hm, I tried replicating this issue, and it will indeed accept something like "12345678-1234-1234-1234-123456789012111". However, I think this is actually an issue with your regex rather than the generator not correctly evaluating the regex.

In the previous example, "12345678-1234-1234-1234-123456789012" is a valid substring and therefore, is accepted.

Try adding ^$ tags to the beginning and end so that the entire string has to be that valid substring

@Foorack
Copy link
Contributor Author

Foorack commented Dec 9, 2021

Hm, I tried replicating this issue, and it will indeed accept something like "12345678-1234-1234-1234-123456789012111". However, I think this is actually an issue with your regex rather than the generator not correctly evaluating the regex.

In the previous example, "12345678-1234-1234-1234-123456789012" is a valid substring and therefore, is accepted.

Try adding ^$ tags to the beginning and end so that the entire string has to be that valid substring

What do you mean? Currently in Rust there is not regex checking at all. Your testing is specific to python server implementation, meanwhile in Rust-server this check is completely missing.

This feature request is to track this missing feature in Rust. I am planning to implement it in a future PR, just wanted to open a tracking Issue ticket first.

@matallui
Copy link

I can confirm that this doesn't seem to be implemented as of v5.3.1. Would love to see this implemented though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants