marshmallow-jsonschema icon indicating copy to clipboard operation
marshmallow-jsonschema copied to clipboard

Add support for marshmallow Regexp validator

Open jcaxmacher opened this issue 8 years ago • 7 comments

jcaxmacher avatar Jan 30 '17 21:01 jcaxmacher

Coverage Status

Coverage decreased (-0.9%) to 99.083% when pulling 8fc9c3789ea58f2fa9d9cb3f6ee0574b4c555061 on obsoleter:master into 6f51771fc809a0762b3d98f4d246b70eb653d802 on fuhrysteve:master.

coveralls avatar Jan 30 '17 21:01 coveralls

Coverage Status

Coverage decreased (-0.9%) to 99.083% when pulling 8fc9c3789ea58f2fa9d9cb3f6ee0574b4c555061 on obsoleter:master into 6f51771fc809a0762b3d98f4d246b70eb653d802 on fuhrysteve:master.

coveralls avatar Jan 30 '17 21:01 coveralls

Coverage Status

Coverage decreased (-0.9%) to 99.083% when pulling 8fc9c3789ea58f2fa9d9cb3f6ee0574b4c555061 on obsoleter:master into 6f51771fc809a0762b3d98f4d246b70eb653d802 on fuhrysteve:master.

coveralls avatar Jan 30 '17 21:01 coveralls

Hi,

thank you for maintaining marshmallow-jsonschema!

Are there any plans to accept this Pull request? Just came across the need to have that, started to write a handler and then saw this pull request...

dim0x69 avatar Jul 10 '19 06:07 dim0x69

Thanks for the bump, @dim0x69

I'm wondering if the regex syntax is the same between python and jsonschema? Does that matter here?

The regular expression syntax used is from JavaScript (ECMA 262, specifically). https://json-schema.org/understanding-json-schema/reference/regular_expressions.html

The python docs seem... unclear about whether they're using a specific / standard syntax?

For details of the theory and implementation of regular expressions, consult the Friedl book [Frie09], or almost any textbook about compiler construction. https://docs.python.org/3/library/re.html#regular-expression-syntax

Regular expressions (called REs, or regexes, or regex patterns) are essentially a tiny, highly specialized programming language embedded inside Python and made available through the re module. https://docs.python.org/3/howto/regex.html#introduction

I'm inclined to merge this as is with the hopes that most common use cases won't run into any meaningful discrepancies, however if you happen to have any insights on the above I'd love to hear

fuhrysteve avatar Jul 10 '19 12:07 fuhrysteve

@fuhrysteve, I'm not sure how accuracte/comprehensive this page is, but it seems to indicate the Regular Expressions in Python have quite a few more features than those in JavaScript (the ECMAScript specification in particular). This would mean that there should be few issues with Python evaluating regular expressions defined in a JSON Schema since JSON Schema specifies the syntax/features of regex as defined in ECMAScript 262.

jcaxmacher avatar Jul 10 '19 13:07 jcaxmacher

Ah so they're at least compatible to a reasonable extent. That makes sense. I created a pull request attempting to merge conflicts, but looks like there are some upstream changes that make the test fail. I can take a look later on!

fuhrysteve avatar Jul 10 '19 13:07 fuhrysteve