mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-07 15:25:41 +01:00
validate hex color strings
This commit is contained in:
parent
7cc940a16c
commit
c75e30fd28
1 changed files with 6 additions and 0 deletions
|
|
@ -171,6 +171,12 @@ class TagSerializer(MatchingModelSerializer):
|
|||
"document_count"
|
||||
)
|
||||
|
||||
def validate_color(self, color):
|
||||
regex = r"#[0-9a-fA-F]{6}"
|
||||
if not re.match(regex, color):
|
||||
raise serializers.ValidationError(_("Invalid color."))
|
||||
return color
|
||||
|
||||
|
||||
class CorrespondentField(serializers.PrimaryKeyRelatedField):
|
||||
def get_queryset(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue