Added comment for why \z.

This commit is contained in:
Carlton Gibson 2020-06-28 14:09:31 +02:00 committed by GitHub
parent 29847a123a
commit e872862a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -554,6 +554,8 @@ class AutoSchema(ViewInspector):
if isinstance(v, URLValidator): if isinstance(v, URLValidator):
schema['format'] = 'uri' schema['format'] = 'uri'
if isinstance(v, RegexValidator): if isinstance(v, RegexValidator):
# In Python, the token \Z does what \z does in other engines.
# https://stackoverflow.com/questions/53283160
schema['pattern'] = v.regex.pattern.replace('\\Z', '\\z') schema['pattern'] = v.regex.pattern.replace('\\Z', '\\z')
elif isinstance(v, MaxLengthValidator): elif isinstance(v, MaxLengthValidator):
attr_name = 'maxLength' attr_name = 'maxLength'