Support for regex POSIX classes. e.g., \p{...} #119
-
I am trying to see if there is any way to support regex POSIX classes like \p{L} or \p{N} with the open-api-schema-validator. In testing, it would appear that the limitation here is that jsonschema uses Is this something that could be addressed by open-api-schema-validator? For reference, here is an example of what I want to accomplish: from openapi_schema_validator import validate
schema = {
"additionalProperties": False,
"type": "object",
"properties": {'name': {'description': 'Sample Name',
'type': 'string',
'pattern': '^([\p{L}\p{Z}\p{N}_.:\/=+\-@]{1,128})$'}
}
}
doc = {'name': 'some-Name'}
validate(doc, schema) This throws an exception:
The import regex
print(regex.match('^([\p{L}\p{Z}\p{N}_.:\/=+\-@]{1,128})$', 'foo')) outputs:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
OpenAPI's regular expressions use syntax of regex from JavaScript (ECMA 262). That means POSIX classes are not part of the standard. You can find equipments in JS here. If you require POSIX classes in your case the best option for you would be to extend openapi validator with pattern validator of your choice. |
Beta Was this translation helpful? Give feedback.
Hi @messedupryan
OpenAPI's regular expressions use syntax of regex from JavaScript (ECMA 262). That means POSIX classes are not part of the standard. You can find equipments in JS here. If you require POSIX classes in your case the best option for you would be to extend openapi validator with pattern validator of your choice.