esim.es2p: Permit ApiParamInteger to be an actual integer

Usually, the specifications say that the integer type is actually
transmitted as a JSON string type.  However, it seems some
implementations do return a native JSON integer type.  Let's be
tolerant in that regard.

Change-Id: I5b47f8bba01225d53eff2ca086e53a2133abed7f
This commit is contained in:
Harald Welte
2024-04-02 21:59:03 +00:00
parent 7aeeb4f475
commit b2b29cfed1

View File

@@ -86,6 +86,8 @@ class ApiParamInteger(ApiParam):
@classmethod
def verify_encoded(cls, data):
if isinstance(data, int):
return
if not data.isdecimal():
raise ValueError('integer (%s) contains non-decimal characters' % data)
assert str(int(data)) == data