Skip to content

feat: add validation of ranged and stepped numerical inputs - #79

Merged
jpbrodrick89 merged 12 commits into
mainfrom
jpb/ranged-inputs
Nov 10, 2025
Merged

jpbrodrick89 merged 12 commits into
mainfrom
jpb/ranged-inputs

Conversation

@jpbrodrick89

Copy link
Copy Markdown
Contributor

Relevant issue or PR

Description of changes

This PR parses the pydantic keys minimum, maximum and multipleOf and applies them as constraints in number_input through min_value, max_value and step.

Testing done

Added some relevant keys to mock schemas. I also reformatted them to make them more maintainable and human-readable.

I have not yet done manual testing.

@jacanchaplais I'd appreciate your input on how else we can test this, should we have an example (mock) Tesseract that uses min and max values?

I'd also like to default to using a slider (w/ synced number input if possible) when min and max is provided, but thought I'd leave that for a future PR. Do you have any thoughts on whether that's a good idea?

@jacanchaplais jacanchaplais left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow @jpbrodrick89, this looks amazing, thank you! I've added some comments, a nit, and a suggestion for some cleaner data structuring, hope that's alright. :)

As for the slider, would this respond well to logarithmically scaled data? I also get a bit wigged out with sliders if the resolution needs to be precise, and I can't hit the number I want haha. Let me know what you think! :)

Comment thread tesseract_streamlit/parse.py Resolved
Comment thread tests/mock-schema-fields.json Resolved
Comment thread tesseract_streamlit/parse.py Resolved
@jacanchaplais

Copy link
Copy Markdown
Collaborator

Also @jpbrodrick89 I like your idea of adding a Tesseract with min / max values. You can use Streamlit's + Typer's testing frameworks as used in test_cli.py to spin up the Tesseract, generate and run the app, then try adding values outside of the numerical bounds.

@jpbrodrick89

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review @jacanchaplais , it seems that UI functionality can't really be tested with .set_value() as this just overrides any constraints. I checked manually and it seems to be working for min and max. It does not work out of the box for step but I think we should leave any custom validation of that for a future PR as quite complex.

@jacanchaplais

jacanchaplais commented Nov 5, 2025 •

Copy link
Copy Markdown
Collaborator

@jpbrodrick89

it seems that UI functionality can't really be tested with .set_value() as this just overrides any constraints.

What about iteratively calling the .increment() / .decrement() methods until the bounds are reached, as documented here?

It does not work out of the box for step but I think we should leave any custom validation of that for a future PR as quite complex.

As in the step doesn't work when you manually test in the web UI? Sounds like the feature is just broken, then? If so, we should either investigate why or remove that feature, since we don't want to introduce non-operational code.

Testing-wise, you could probably also use the .increment() / .decrement() methods along with the .value attribute to check the step, right?

@jpbrodrick89

Copy link
Copy Markdown
Contributor Author

I mean step correctly steps up in the correct increments but it doesn't perform validation if you manually input incorrect values. I'll try the increment/decrement methods you recommend though to toughen up the testing.

@jpbrodrick89

Copy link
Copy Markdown
Contributor Author

Unfortunately increment and decrement override min_value and max_value too 🙁 ... but not step so added that. I think this is as good as we can get.

@jacanchaplais jacanchaplais left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow reply @jpbrodrick89! LGTM, thanks :)

@jpbrodrick89
jpbrodrick89 merged commit f0e5da5 into main Nov 10, 2025
8 checks passed
@jpbrodrick89
jpbrodrick89 deleted the jpb/ranged-inputs branch November 10, 2025 18:25
@pasteurlabs pasteurlabs locked and limited conversation to collaborators Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants