mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
* Don't allow the first and last addresses being assigned #1241 Show all e-mail addresses associated with a username #1291 Add permission 'manage peering sessions' #1290 Put an Icon next to user name on https://www.peeringdb.com/org/nnnn#users if the user is using U2F #1238 Tie TOTP devices and Webauthn Security Keys to the user account #1339 v2 Search (#1204) pin django peeringdb 3.0.1 and poetry relock linting * fix codeql warning: DOM text reinterpreted as HTML * fix global stats tests --------- Co-authored-by: 20C <code@20c.com>
154 lines
2.8 KiB
Markdown
154 lines
2.8 KiB
Markdown
Generated from validators.py on 2023-04-12 10:09:44.563425
|
|
|
|
# peeringdb_server.validators
|
|
|
|
peeringdb model / field validators
|
|
|
|
# Functions
|
|
---
|
|
|
|
## validate_address_space
|
|
`def validate_address_space(prefix)`
|
|
|
|
Validate an ip prefix according to peeringdb specs.
|
|
|
|
Arguments:
|
|
- prefix: ipaddress.IPv4Network or an ipaddress.IPv6Network
|
|
|
|
Raises:
|
|
- ValidationError on failed validation
|
|
|
|
---
|
|
## validate_api_rate
|
|
`def validate_api_rate(value)`
|
|
|
|
Validates a number/time-unit format used to determine rate limits
|
|
|
|
e.g., 10/second or 100/minute
|
|
|
|
Will raise a ValidationError on failure
|
|
|
|
Arguments:
|
|
|
|
- value(`str`)
|
|
|
|
Returns:
|
|
|
|
- validated value (`str`)
|
|
|
|
---
|
|
## validate_bool
|
|
`def validate_bool(value)`
|
|
|
|
Validates a boolean value
|
|
|
|
This can be passed a string for `True` or `False` or an integer as 1, 0 as well
|
|
to convert and return a boolean value
|
|
|
|
Will raise ValidationError on failure.
|
|
|
|
Arguments:
|
|
|
|
- value (`str`|`int`|`bool`)
|
|
|
|
Returns:
|
|
|
|
- validated value (`bool`)
|
|
|
|
---
|
|
## validate_irr_as_set
|
|
`def validate_irr_as_set(value)`
|
|
|
|
Validate irr as-set string.
|
|
|
|
- the as-set/rs-set name has to conform to RFC 2622 (5.1 and 5.2)
|
|
- the source may be specified by AS-SET@SOURCE or SOURCE::AS-SET
|
|
- multiple values must be separated by either comma, space or comma followed by space
|
|
|
|
Arguments:
|
|
|
|
- value: irr as-set string
|
|
|
|
Returns:
|
|
|
|
- str: validated irr as-set string
|
|
|
|
---
|
|
## validate_phonenumber
|
|
`def validate_phonenumber(phonenumber, country=None)`
|
|
|
|
Validate a phonenumber to E.164
|
|
|
|
Arguments:
|
|
- phonenumber (str)
|
|
|
|
Raises:
|
|
- ValidationError if phone number isn't valid E.164 and cannot
|
|
be made E.164 valid
|
|
|
|
Returns:
|
|
- str: validated phonenumber
|
|
|
|
---
|
|
## validate_prefix
|
|
`def validate_prefix(prefix)`
|
|
|
|
Validate ip prefix.
|
|
|
|
Arguments:
|
|
- prefix: ipaddress.IPv4Network or an ipaddress.IPv6Network
|
|
|
|
Raises:
|
|
- ValidationError on failed validation
|
|
|
|
Returns:
|
|
- ipaddress.ip_network instance
|
|
|
|
---
|
|
## validate_prefix_overlap
|
|
`def validate_prefix_overlap(prefix)`
|
|
|
|
Validate that a prefix does not overlap with another prefix
|
|
on an already existing ixlan.
|
|
|
|
Arguments:
|
|
- prefix: ipaddress.IPv4Network or an ipaddress.IPv6Network
|
|
|
|
Raises:
|
|
- ValidationError on failed validation
|
|
|
|
---
|
|
## validate_social_media
|
|
`def validate_social_media(value)`
|
|
|
|
Validates a social media value
|
|
|
|
Will raise a ValidationError on failure
|
|
|
|
Arguments:
|
|
|
|
- value(`dict`)
|
|
|
|
Returns:
|
|
|
|
- validated value (`dict`)
|
|
|
|
---
|
|
## validate_zipcode
|
|
`def validate_zipcode(zipcode, country)`
|
|
|
|
Validate a zipcode for a country. If a country has zipcodes, a zipcode
|
|
is required. If a country does not have zipcodes, it's not required.
|
|
|
|
|
|
Arguments:
|
|
- zipcode (can be Str or None at this point)
|
|
- country (two-letter country-code provided in data)
|
|
Raises:
|
|
- ValidationError if Zipcode is missing from a country WITH
|
|
zipcodes
|
|
Returns:
|
|
- str: zipcode
|
|
|
|
---
|