pySim-shell: Reject any non-decimal PIN values
Don't even send any non-decimal PIN values to the card, but reject
them when parsing the command arguments.
Change-Id: Icec1698851471af7f76f20201dcdcfcd48ddf365
diff --git a/pySim/utils.py b/pySim/utils.py
index ea1c9e6..44800fb 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1487,3 +1487,10 @@
if len(instr) & 1:
raise ValueError('Input has un-even number of hex digits')
return instr
+
+def is_decimal(instr: str) -> str:
+ """Method that can be used as 'type' in argparse.add_argument() to validate the value consists of
+ an even sequence of decimal digits only."""
+ if not instr.isdecimal():
+ raise ValueError('Input must decimal')
+ return instr