1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

fix sourceless irr validation (#706)

Co-authored-by: Stefan Pratter <stefan@20c.com>
This commit is contained in:
Matt Griswold
2020-04-23 08:49:53 -05:00
committed by GitHub
parent a4f72d3c2e
commit 095422f0f5
2 changed files with 13 additions and 5 deletions

View File

@@ -195,9 +195,12 @@ def validate_irr_as_set(value):
source = parts_match.group(1)
as_set = parts_match.group(2)
else:
raise ValidationError(_("Invalid formatting: {} - should be AS-SET@SOURCE or SOURCE::AS-SET").format(item))
sourceless_match = re.match("^([\w\d\-:]+)$", item)
as_set = sourceless_match.group(1)
if not sourceless_match:
raise ValidationError(_("Invalid formatting: {} - should be AS-SET, ASx, AS-SET@SOURCE or SOURCE::AS-SET").format(item))
if source not in IRR_SOURCE:
if source and source not in IRR_SOURCE:
raise ValidationError(_("Unknown IRR source: {}").format(source))