Skip to content

Commit

Permalink
communities: schema: Validate slug id to exclude reserved keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 committed Sep 24, 2024
1 parent 8b46ac6 commit c941fae
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions invenio_communities/communities/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ def is_not_uuid(value):
pass


def is_not_reserved(value):
"""Make sure value is not a reserved keyword."""
return validate.NoneOf(
iterable=["new"], error=("The ID cannot be a reserved keyword.")
)


class CommunityAccessSchema(Schema):
"""Community Access Schema."""

Expand Down Expand Up @@ -233,6 +240,7 @@ class Meta:
),
),
is_not_uuid,
is_not_reserved,
],
)
metadata = NestedAttribute(CommunityMetadataSchema, required=True)
Expand Down

0 comments on commit c941fae

Please sign in to comment.