jsonmodels icon indicating copy to clipboard operation
jsonmodels copied to clipboard

validators: add option for non-ECMA regex validation

Open omriarad opened this issue 7 years ago • 5 comments

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

omriarad avatar Jan 08 '18 20:01 omriarad

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.)

beregond avatar Jan 31 '18 20:01 beregond

In that case maybe validators.PythonRegex class might make sense since we do want to actually validate the value.

avrahamshukron avatar Jan 31 '18 21:01 avrahamshukron

Yeah, this would make sense actually, but alongside ECMARegex would be required too. And we cannot remove Regex class anyway for backward compatibility.

beregond avatar Feb 03 '18 07:02 beregond

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

avrahamshukron avatar Feb 03 '18 12:02 avrahamshukron

I think this PR should be closed since it is followed by #108 which fixes the issues with this PR.

avrahamshukron avatar Oct 28 '18 19:10 avrahamshukron