diff options
author | Devaev Maxim <[email protected]> | 2019-10-15 05:29:01 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-10-15 05:29:15 +0300 |
commit | e58ad66da98917d66f58731d041d4ddbe18befed (patch) | |
tree | cf9d0c9a92eac227427b352d607558733db13fa9 /kvmd/validators | |
parent | a88ad42501e3afd49bb02f186e787b6e14474640 (diff) |
some validation
Diffstat (limited to 'kvmd/validators')
-rw-r--r-- | kvmd/validators/hw.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kvmd/validators/hw.py b/kvmd/validators/hw.py index a68743ad..82d1221a 100644 --- a/kvmd/validators/hw.py +++ b/kvmd/validators/hw.py @@ -23,6 +23,7 @@ from typing import Any from . import check_in_list +from . import check_re_match from .basic import valid_number @@ -40,3 +41,11 @@ def valid_gpio_pin(arg: Any) -> int: def valid_gpio_pin_optional(arg: Any) -> int: return int(valid_number(arg, min=-1, name="optional GPIO pin")) + + +def valid_otg_gadget(arg: Any) -> str: + return check_re_match(arg, "OTG gadget name", r"^[a-z_][a-z0-9_-]*$")[:255] + + +def valid_otg_id(arg: Any) -> int: + return int(valid_number(arg, min=0, max=65535, name="OTG ID")) |