jsonmodels
jsonmodels copied to clipboard
validators: add option for non-ECMA regex validation
this allows more flexibility with exporting the generated schema with other implementations. according to the JSON schema the pattern SHOULD be ECMA but not necessarily.
Implements #102
Nice, but actually since this is going to be some 'generic' validator - why not create other class for it? I mean ecma=True is just a switch that changes most of bahaviour - it should be distinct validators.GenericRegex - you could simply copy actual Regex and remove flags, translation etc*.
(*Actually since this is generic regex you could/should remove actual validation too - if you don't know what language it is in - you cannot validate it. And if you know (that this is ie PCRE or python expression then such class wouldn't be generic either.)
In that case maybe validators.PythonRegex class might make sense since we do want to actually validate the value.
Yeah, this would make sense actually, but alongside ECMARegex would be required too. And we cannot remove Regex class anyway for backward compatibility.
Will work on that soon.
In any case the lack of this validator is not a big deal since the library enables anyone to write such validator themselves
I think this PR should be closed since it is followed by #108 which fixes the issues with this PR.