You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't get the "const" keyword to work properly for string values:
In [12]: fastjsonschema.compile({"const": "a"})("a")
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-12-ab19503ee02c> in <module>()
----> 1 fastjsonschema.compile({"const": "a"})("a")
<string> in validate(data)
NameError: name 'a' is not defined
Looking the code produced by the compile_to_code function, it seems that the value "a" is just not properly quoted:
VERSION = "2.3"
from fastjsonschema import JsonSchemaException
NoneType = type(None)
def validate(data):
if data != a:
raise JsonSchemaException("data must be same as const definition")
return data
Indeed, it works for values that don't require quoting, like integers.
The text was updated successfully, but these errors were encountered:
I can't get the "const" keyword to work properly for string values:
Looking the code produced by the
compile_to_code
function, it seems that the value "a" is just not properly quoted:Indeed, it works for values that don't require quoting, like integers.
The text was updated successfully, but these errors were encountered: