Skip validation for non-string values
@@ -418,6 +418,7 @@ class IS_JSON(Validator):
self.error_message = error_message
def validate(self, value, record_id=None):
+ if isinstance(value, (str, bytes)):
try:
if self.native_json:
json.loads(value) # raises error in case of malformed json
@@ -426,6 +427,8 @@ class IS_JSON(Validator):
return json.loads(value)
except JSONErrors:
raise ValidationError(self.translator(self.error_message))
+ else:
+ return value
def formatter(self, value):
if value is None:
