feat(ui): configurable field constraints for number fields in form builder #7787
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Allow for the min and max values for Integer and Float Node Field elements in the Form Builder to be configured.
For example, the
Noise
node'swidth
field is an integer from a min of 1 and no max, with amultipleOf
constraint of 8.Let's see how that gets parsed into the UI:
multipleOf=8
constraint, the effective min is the smallest multiple of 8 that is greater than or equal to the min. So the effective min is 8.multipleOf
when setting min value for number inputs. In this example, you'd be able to leave the min on the noise node at 1, which would error if you Invoked. So this PR resolves a that footgun.multipleOf
constraint, the effective max is the largest mutliple of 8 that is less than or equal to this constant. That turns out to be 4294967288.multipleOf
value is used as the "step" for number inputs and sliders. So in this case, each notch on the slider or increment/decrement of the number input jumps by 8.Ok - that's the field as defined in the node, without any user-configured constraints. We'll call these the inherited values.
If the user overrides the min and max, the override values are constrained first by each other and then by inherited values if no overrides are set. It is not possible to set the overrides in such a way that they are any less strict than the inherited values - they can only be as strict or stricter.
I started writing a specific numerical example, but it's way easier to just show how it works:
Screen.Recording.2025-03-14.at.9.11.23.pm.mov
Caveats:
There is no override for
multipleOf
(akastep
). It's possible to add it but I'd had enough of this math-y stuff for the day and didn't get to it. Can revisit if needed.The min and max overrides are inclusive. Exclusive min and max are tricky to represent on a slider. Can revisit if needed.
The override values are not applied to the node field directly. In edit mode, it is possible to set the values to something outside the range of the overrides by changing the value directly on the node. For example, if the max width override was set to 1024 in the form, it's possible to click edit and select a higher value in the node directly.
I think the node fields should stay 1-to-1 mapped to the python nodes and the form constraints should not be applied to the nodes.
If somebody edits the node field directly and sets a value outside the form builder's overrides, there is no error indicator. It's possible to add it but it's an decent extra layer of complexity, and I am not convinced this edge case is worth the time. Can revisit if needed.
Related Issues / Discussions
Many convos on discord and offline
QA Instructions
Try it out. Try to break it from the form builder UI.
Merge Plan
n/a
Checklist
What's New
copy (if doing a release after this PR)