{"record":{"id":"48206fbfa60ae9a8","repo":"material-components/material-components-android","slug":"valuefrom-s-must-be-smaller-than-valueto-s","errorCode":null,"errorMessage":"valueFrom(%s) must be smaller than valueTo(%s)","messagePattern":"valueFrom\\((.+?)\\) must be smaller than valueTo\\((.+?)\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/slider/BaseSlider.java","lineNumber":745,"sourceCode":"    return Math.abs(Math.round(result) - result) < THRESHOLD;\n  }\n\n  private void validateStepSize() {\n    if (stepSize > 0.0f && !valueLandsOnTick(valueTo)) {\n      throw new IllegalStateException(\n          String.format(EXCEPTION_ILLEGAL_STEP_SIZE, stepSize, valueFrom, valueTo));\n    }\n  }\n\n  private void validateValues() {\n    if (valueFrom >= valueTo) {\n      throw new IllegalStateException(\n          String.format(EXCEPTION_ILLEGAL_VALUE_FROM, valueFrom, valueTo));\n    }\n\n    for (Float value : values) {\n      if (value < valueFrom || value > valueTo) {\n        throw new IllegalStateException(\n            String.format(EXCEPTION_ILLEGAL_VALUE, value, valueFrom, valueTo));\n      }\n      if (stepSize > 0.0f && !valueLandsOnTick(value)) {\n        throw new IllegalStateException(\n            String.format(EXCEPTION_ILLEGAL_DISCRETE_VALUE, value, valueFrom, stepSize, stepSize));\n      }\n    }\n  }\n\n  private void validateMinSeparation() {\n    final float minSeparation = getMinSeparation();\n    if (minSeparation < 0) {\n      throw new IllegalStateException(\n          String.format(EXCEPTION_ILLEGAL_MIN_SEPARATION, minSeparation));\n    }\n    if (stepSize > 0 && minSeparation > 0) {\n      if (separationUnit != UNIT_VALUE) {\n        throw new IllegalStateException(","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/slider/BaseSlider.java#L727-L763","documentation":"Thrown by validateValues() when valueFrom is greater than or equal to valueTo, which would produce an empty or inverted slider range. Like the other slider validations it fires when the view is laid out, not when the setter runs, so a bad pair can be set without error and crash later.","triggerScenarios":"Calling setValueTo(v) with v <= valueFrom, or setValueFrom(v) with v >= valueTo; loading app:valueFrom/app:valueTo from XML with equal or swapped values; building an RTL-localized 'reversed' slider by swapping from/to instead of using layout direction.","commonSituations":"Data-driven sliders where both bounds come from a config or API and the API occasionally returns min == max or min > max; copy-paste XML where only one bound was updated; attempting to invert a slider by swapping the values.","solutions":["Ensure valueFrom < valueTo strictly; equal values are also rejected.","Clamp/sanitize dynamic bounds before applying: if (min >= max) max = min + 1 (or skip the update).","To visually reverse a slider, keep valueFrom < valueTo and use android:supportsRtl / layoutDirection, not swapped values.","Check the ordering every time either bound is changed programmatically."],"exampleFix":"// before\nslider.setValueFrom(10f);\nslider.setValueTo(10f); // equal -> IllegalStateException on layout\n\n// after\nslider.setValueFrom(0f);\nslider.setValueTo(10f);","handlingStrategy":"validation","validationCode":"static boolean rangeValid(float from, float to) { return from < to; }\n// if (rangeValid(min, max)) { slider.setValueFrom(min); slider.setValueTo(max); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat (valueFrom, valueTo) as an inseparable pair; update both from one sanitized source.","Skip the update when a dynamic range arrives inverted or empty instead of applying it.","Never swap from/to to reverse a slider; use RTL layout direction."],"tags":["android","slider","material-components","configuration","layout-time"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}