Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/galaxy/util/validation.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:32:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d30785e31577 | 1:56ad4e20f292 |
|---|---|
| 1 """ Module for validation of incoming inputs. | |
| 2 | |
| 3 TODO: Refactor BaseController references to similar methods to use this module. | |
| 4 """ | |
| 5 from six import string_types | |
| 6 | |
| 7 from galaxy import exceptions | |
| 8 from galaxy.util.sanitize_html import sanitize_html | |
| 9 | |
| 10 | |
| 11 def validate_and_sanitize_basestring(key, val): | |
| 12 if not isinstance(val, string_types): | |
| 13 raise exceptions.RequestParameterInvalidException('%s must be a string or unicode: %s' | |
| 14 % (key, str(type(val)))) | |
| 15 return sanitize_html(val) | |
| 16 | |
| 17 | |
| 18 def validate_and_sanitize_basestring_list(key, val): | |
| 19 try: | |
| 20 assert isinstance(val, list) | |
| 21 return [sanitize_html(t) for t in val] | |
| 22 except (AssertionError, TypeError): | |
| 23 raise exceptions.RequestParameterInvalidException('%s must be a list of strings: %s' | |
| 24 % (key, str(type(val)))) | |
| 25 | |
| 26 | |
| 27 def validate_boolean(key, val): | |
| 28 if not isinstance(val, bool): | |
| 29 raise exceptions.RequestParameterInvalidException('%s must be a boolean: %s' | |
| 30 % (key, str(type(val)))) | |
| 31 return val | |
| 32 | |
| 33 | |
| 34 # TODO: | |
| 35 # def validate_integer(self, key, val, min, max): | |
| 36 # def validate_float(self, key, val, min, max): | |
| 37 # def validate_number(self, key, val, min, max): | |
| 38 # def validate_genome_build(self, key, val): |
