You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
used the search to make sure that a similar issue hasn't already been submit
Expected Behavior
I am implementing regex validation via the pattern keyword annotation for my api:
/**
* Allows for more generic naming, but disallows general punctuation, line breaks and non unicode letters/numbers
* @pattern ^[\p{N}\p{L}\h]{0,62}$ Generic name failed validation pattern
*/
type GenericName = string
The provided @pattern regex with it's provided unicode classes (e.g. \p{L}) should match generic names such as: Müller, Åman, Project 123 etc and throw an error if the request string is invalid.
Current Behavior
It seems that unicode classes are not supported by whatever regex engine TSOA runs on, since my api throws the @pattern's error message even though the request parameter string is clearly valid. However, If I exchange the regex pattern with a non unicode regex (^[a-zA-Z0-9-\h]*$ or anything similar) the validation works as intended.
Attempted Solutions
I have double checked that the regex is correct
I have tried adding the /u (unicode) flag to my regex
I have also tried removing the escaping backslash generated by TSOA in the swagger.json file, but to no avail.
Maintainer Note
If unicode regex is supported please provide a working example, if not then we would greatly desire such a feature since we use a lot of regex validation with unicode for our api.
Swagger File
The auto generated swagger.json file looks like this:
"schemas": {
"GenericName": {
"type": "string",
"description": "Allows for more generic naming, but disallows general punctuation and line breaks and non unicode letters/numbers",
"pattern": "^[\\p{N}\\p{L}\\h]{0,62}$"
}
}
Context (Environment)
Version of the library: 4.1.3
Version of NodeJS: 16.14.2
Package manager: npm
The text was updated successfully, but these errors were encountered:
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
I am implementing regex validation via the pattern keyword annotation for my api:
The provided @pattern regex with it's provided unicode classes (e.g. \p{L}) should match generic names such as: Müller, Åman, Project 123 etc and throw an error if the request string is invalid.
Current Behavior
It seems that unicode classes are not supported by whatever regex engine TSOA runs on, since my api throws the @pattern's error message even though the request parameter string is clearly valid. However, If I exchange the regex pattern with a non unicode regex (^[a-zA-Z0-9-\h]*$ or anything similar) the validation works as intended.
Attempted Solutions
I have double checked that the regex is correct
I have tried adding the /u (unicode) flag to my regex
I have also tried removing the escaping backslash generated by TSOA in the swagger.json file, but to no avail.
Maintainer Note
If unicode regex is supported please provide a working example, if not then we would greatly desire such a feature since we use a lot of regex validation with unicode for our api.
Swagger File
The auto generated swagger.json file looks like this:
Context (Environment)
Version of the library: 4.1.3
Version of NodeJS: 16.14.2
Package manager: npm
The text was updated successfully, but these errors were encountered: