You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/08/12 11:40:04 UTC

[GitHub] [superset] villebro commented on a change in pull request #16230: fix(explore): conditional formatting value validators

villebro commented on a change in pull request #16230:
URL: https://github.com/apache/superset/pull/16230#discussion_r687631236



##########
File path: superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx
##########
@@ -57,6 +57,131 @@ const operatorOptions = [
   { value: COMPARATOR.BETWEEN_OR_RIGHT_EQUAL, label: '< x ≤' },
 ];
 
+const targetValueLeftValidator = (rightValue?: number) => (
+  _: any,
+  value?: number,
+) => {
+  if (!value || !rightValue || Number(rightValue) > Number(value)) {
+    return Promise.resolve();
+  }
+  return Promise.reject(
+    new Error(t('This value should be smaller than the right target value')),
+  );
+};
+
+const targetValueRightValidator = (leftValue?: number) => (

Review comment:
       I might be swatting a fly with a sledge hammer, but it could be nice to have a `targetValueValidator` that encapsulates the repeated logic here.




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org