mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-20 04:26:53 +00:00
Fix: reject invalid zone validation regexes on save
A bad pattern made every extraction fail the regex check.
This commit is contained in:
1 parent
0f4a71ed88
commit
884fbf7fb2
2 files changed
+65
-1
No files matched your search
@@ -3770,6 +3770,16 @@ class OcrTemplateZoneSerializer(serializers.ModelSerializer):
|
||||
)
|
||||
return value
|
||||
|
||||
def validate_validation_regex(self, value: str) -> str:
|
||||
if value:
|
||||
try:
|
||||
validate_regex_pattern(value)
|
||||
except ValueError as e:
|
||||
raise serializers.ValidationError(
|
||||
f"Invalid regular expression: {e}",
|
||||
) from e
|
||||
return value
|
||||
|
||||
def validate_page(self, value):
|
||||
if value is not None and value != -1 and value < 1:
|
||||
raise serializers.ValidationError(
|
||||
|
||||
Reference in new issue
Block a user