Last active
September 13, 2024 20:25
-
-
Save dawidgora/464e065d79d2791fddf61d7b0367c7ef to your computer and use it in GitHub Desktop.
Simple bulk uuid v4 validator generated by GPT-4o
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
def is_valid_uuid4(u): | |
try: | |
val = uuid.UUID(u, version=4) | |
# Check if it is truly a UUID4 (random) and not any other UUID type. | |
return str(val) == u and val.version == 4 | |
except ValueError: | |
return False | |
def main(): | |
print("Please paste a list of UUIDs (one per line). Press Enter on an empty line to finish:") | |
# Capture multiple lines of input from the user | |
uuid_list = [] | |
while True: | |
user_input = input().strip() | |
if not user_input: | |
break | |
uuid_list.append(user_input) | |
invalid_uuids = [] | |
valid_uuid4_count = 0 | |
# Check each UUID in the list | |
for u in uuid_list: | |
if is_valid_uuid4(u): | |
valid_uuid4_count += 1 | |
else: | |
invalid_uuids.append(u) | |
# Print results | |
if invalid_uuids: | |
print("\nInvalid UUIDs:") | |
for invalid_uuid in invalid_uuids: | |
print(invalid_uuid) | |
else: | |
print("\nNo invalid UUIDs found.") | |
print(f"\nNumber of valid UUIDv4: {valid_uuid4_count}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment