From 4647a169611e95f535bc74e884b2cc71cdf8b61c Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Wed, 27 Dec 2023 17:37:13 -0800 Subject: [PATCH] Adds in some additional validators for a nicer error message --- src/paperless/migrations/0001_initial.py | 7 ++++++- src/paperless/models.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/paperless/migrations/0001_initial.py b/src/paperless/migrations/0001_initial.py index 96f06f6ca..80d74cea4 100644 --- a/src/paperless/migrations/0001_initial.py +++ b/src/paperless/migrations/0001_initial.py @@ -50,8 +50,10 @@ class Migration(migrations.Migration): ( "pages", models.PositiveIntegerField( - blank=True, null=True, + validators=[ + django.core.validators.MinValueValidator(1), + ], verbose_name="Do OCR from page 1 to this value", ), ), @@ -97,6 +99,9 @@ class Migration(migrations.Migration): "image_dpi", models.PositiveIntegerField( null=True, + validators=[ + django.core.validators.MinValueValidator(1), + ], verbose_name="Sets image DPI fallback value", ), ), diff --git a/src/paperless/models.py b/src/paperless/models.py index 1edb460f9..74db4726a 100644 --- a/src/paperless/models.py +++ b/src/paperless/models.py @@ -93,7 +93,7 @@ class ApplicationConfiguration(AbstractSingletonModel): pages = models.PositiveIntegerField( verbose_name=_("Do OCR from page 1 to this value"), null=True, - blank=True, + validators=[MinValueValidator(1)], ) language = models.CharField( @@ -122,6 +122,7 @@ class ApplicationConfiguration(AbstractSingletonModel): image_dpi = models.PositiveIntegerField( verbose_name=_("Sets image DPI fallback value"), null=True, + validators=[MinValueValidator(1)], ) # Can't call it clean, that's a model method