From 9fb474d3be3e83c99b31c62a6d5adcd2d748bfd9 Mon Sep 17 00:00:00 2001 From: marcsello Date: Fri, 2 Oct 2020 04:21:33 +0200 Subject: [PATCH] Ensure minimum length --- src/resources.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/resources.py b/src/resources.py index 29bd1f2..a0a04b3 100644 --- a/src/resources.py +++ b/src/resources.py @@ -58,7 +58,10 @@ class SampleResource(Resource): return {'err_msg': 'Input JSON schema invalid'}, 417 xeger = Xeger(limit=30) - generated_tag = xeger.xeger(r'^[a-zA-Z]+[0-9a-zA-Z_]*$')[:32] + while True: + generated_tag = xeger.xeger(r'^[a-zA-Z]+[0-9a-zA-Z_]*$')[:32] + if len(generated_tag) > 2: # Ensure minimum length + break record = SampleMetadata( device_id=desc['device_id'],