Skip to main content

index/functions/validateMinMaxRelationship.md

validateMinMaxRelationship(min, max, minLabel, maxLabel): void

Validates that min <= max constraint is satisfied.

Ensures that a minimum value does not exceed the maximum value. Supports both string and numeric inputs for flexibility.

Parameters​

ParameterTypeDescription
minstring | numberMinimum value (can be number or string)
maxstring | numberMaximum value (can be number or string)
minLabelstringLabel for minimum value (e.g., 'minPrice') for error messages
maxLabelstringLabel for maximum value (e.g., 'maxPrice') for error messages

Returns​

void

Throws​

If min > max

Examples​

// Valid: min < max
validateMinMaxRelationship(0.5, 1.0, 'minPrice', 'maxPrice');
// Valid: min = max
validateMinMaxRelationship(100, 100, 'minLiquidity', 'maxLiquidity');
// Invalid: min > max
validateMinMaxRelationship(10, 5, 'startTick', 'endTick'); // throws