2023-11-22 13:56:52 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
def validate_freedata_callsign(callsign):
|
2024-01-28 21:48:28 +00:00
|
|
|
#regexp = "^[a-zA-Z]+\d+\w+-\d{1,2}$"
|
2024-02-05 20:57:56 +00:00
|
|
|
regexp = "^[A-Za-z0-9]{1,7}-[0-9]{1,3}$" # still broken - we need to allow all ssids form 0 - 255
|
2023-11-22 13:56:52 +00:00
|
|
|
return re.compile(regexp).match(callsign) is not None
|
2024-01-18 10:35:44 +00:00
|
|
|
|
|
|
|
def validate_message_attachment(attachment):
|
|
|
|
for field in ['name', 'type', 'data']:
|
|
|
|
if field not in attachment:
|
|
|
|
raise ValueError(f"Attachment missing '{field}'")
|
2024-02-08 09:06:46 +00:00
|
|
|
|
|
|
|
# check for content length, except type
|
|
|
|
# there are some files out there, don't having a mime type
|
|
|
|
if len(attachment[field]) < 1 and field not in ["type"]:
|
2024-01-18 10:35:44 +00:00
|
|
|
raise ValueError(f"Attachment has empty '{field}'")
|