Commit cc910986 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Validation of strings simplified

parent 786ba61e
Pipeline #10639 passed with stage
in 51 seconds
......@@ -44,14 +44,14 @@ def validate_input(**kwargs):
an `APIArgumentError` exception is raised
"""
def wrap(name, message, regexp, can_skip=False):
re_regexp = re.compile(regexp)
re_regexp = re.compile(regexp, re.IGNORECASE)
if not test_input_with_regex(kwargs, name, re_regexp) and not can_skip:
arg = kwargs.get(name) if kwargs.get(name) is not None else '<<None>>'
raise APIArgumentError("Invalid {0} ({1}) - {2}".format(name, arg, message))
wrap('referenceName',
'accepted ones are: 1-22, X, Y, M, MT',
r'^([1-9]|1\d|2[012]|[Xx]|[Yy]|[Mm][Tt]?)$')
r'^([1-9]|1\d|2[012]|x|y|mt?)$')
wrap('start',
'should be a positive number',
......@@ -85,21 +85,20 @@ def validate_input(**kwargs):
wrap('assemblyId',
'accepted ones are: GRCh38, GRCh37 and NCBI36',
r'^([Gg][Rr][Cc][Hh](38|37)|[Nn][Cc][Bb][Ii]36)$')
r'^(grch(38|37)|ncbi36)$')
wrap('referenceBases',
'should contain only A, C, T, G, D',
r'^[AaCcTtGgDd]*$')
r'^[actgd]*$')
wrap('alternateBases',
'should contain only A, C, T, G, D',
r'^[AaCcTtGgDd]*$',
r'^[actgd]*$',
True)
wrap('includeDatasetResponses',
'accepts only "ALL", "HIT", "MISS", "NONE" and empty string',
r'^([Hh][Ii][Tt]$)|([Aa][Ll]{2}$)|([Mm][Ii][Ss]{2}$)|([Nn][Oo][Nn][Ee]$)|($)',
True)
r'^(hit|all|miss|none)?$')
return True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment