+
{this.props.t('widget.Table.validation', 'Validation')}
+
+
+ this.onColumnItemChange(index, 'minValue', value)}
+ componentName={this.getPopoverFieldSource(column.columnType, 'minValue')}
+ />
+
+
+
+ this.onColumnItemChange(index, 'maxValue', value)}
+ componentName={this.getPopoverFieldSource(column.columnType, 'maxValue')}
+ />
+
+
+ )}
+
{column.columnType === 'toggle' && (
diff --git a/frontend/src/_helpers/utils.js b/frontend/src/_helpers/utils.js
index b3cb5d218b..fcd9a4021d 100644
--- a/frontend/src/_helpers/utils.js
+++ b/frontend/src/_helpers/utils.js
@@ -248,6 +248,8 @@ export function validateWidget({ validationObject, widgetValue, currentState, cu
const regex = validationObject?.regex?.value;
const minLength = validationObject?.minLength?.value;
const maxLength = validationObject?.maxLength?.value;
+ const minValue = validationObject?.minValue?.value;
+ const maxValue = validationObject?.maxValue?.value;
const customRule = validationObject?.customRule?.value;
const validationRegex = resolveWidgetFieldValue(regex, currentState, '', customResolveObjects);
@@ -278,6 +280,26 @@ export function validateWidget({ validationObject, widgetValue, currentState, cu
}
}
+ const resolvedMinValue = resolveWidgetFieldValue(minValue, currentState, undefined, customResolveObjects);
+ if (resolvedMinValue !== undefined) {
+ if (widgetValue < parseInt(resolvedMinValue)) {
+ return {
+ isValid: false,
+ validationError: `Minimum value is ${resolvedMinValue}`,
+ };
+ }
+ }
+
+ const resolvedMaxValue = resolveWidgetFieldValue(maxValue, currentState, undefined, customResolveObjects);
+ if (resolvedMaxValue !== undefined) {
+ if (widgetValue > parseInt(resolvedMaxValue)) {
+ return {
+ isValid: false,
+ validationError: `Maximum value is ${resolvedMaxValue}`,
+ };
+ }
+ }
+
const resolvedCustomRule = resolveWidgetFieldValue(customRule, currentState, false, customResolveObjects);
if (typeof resolvedCustomRule === 'string') {
return { isValid: false, validationError: resolvedCustomRule };