uranusjr commented on code in PR #31140:
URL: https://github.com/apache/airflow/pull/31140#discussion_r1189495795
##########
airflow/www/validators.py:
##########
@@ -76,3 +78,22 @@ def __call__(self, form, field):
except JSONDecodeError as ex:
message = self.message or f"JSON Validation Error: {ex}"
raise
ValidationError(message=field.gettext(message.format(field.data)))
+
+
+class ValidKey:
+ """
+ Validates values that will be used as keys
+
+ :param max_length:
+ The maximum length of the given key
+ """
+
+ def __init__(self, max_length=200):
+ self.max_length = max_length
+
+ def __call__(self, form, field):
+ if field.data:
+ try:
+ helpers.validate_key(field.data, self.max_length)
+ except Exception as e:
+ raise ValidationError(e)
Review Comment:
```suggestion
raise ValidationError(str(e))
```
The first argument of ValidationError is supposed to be a string, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]