From 3933e4980b5fbe6632fe451e3c6a8edecf97c4a8 Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Sat, 21 Mar 2020 10:11:23 -0400 Subject: [PATCH] Fix the _verifyInt() and verifyFloating() functions for test validation --- OpenBench/utils.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/OpenBench/utils.py b/OpenBench/utils.py index daa16ff..2290fea 100644 --- a/OpenBench/utils.py +++ b/OpenBench/utils.py @@ -129,14 +129,12 @@ def verifyNewTest(request): errors = [] def verifyInteger(field, fieldName): - if not request.POST[field].isnumeric(): - errors.append('{0} is not an Integer'.format(fieldName)) + try: int(request.POST[field]) + except: errors.append('{0} is not an Integer'.format(fieldName)) def verifyFloating(field, fieldName): - if not request.POST[field].replace('.','').isnumeric(): - errors.append('{0} is not a Float'.format(fieldName)) - elif request.POST[field].count('.') > 1: - errors.append('{0} is not a Float'.format(fieldName)) + try: float(request.POST[field]) + except: errors.append('{0} is not a Floating Point'.format(fieldName)) def verifyLessThan(field, fieldName, value, valueName): if not float(request.POST[field]) < value: