Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max value #78

Open
stevenjob opened this issue Jul 5, 2017 · 1 comment
Open

Max value #78

stevenjob opened this issue Jul 5, 2017 · 1 comment
Labels

Comments

@stevenjob
Copy link
Contributor

As a dev i want to be able to stop the user setting the value of finput above a configured value of my choice.

I think i can do this outside of finput using some checks and setValue but could be nicer to have a config option similar to scale.

@chrisprice is this something you want out of finput for its long-term maintainability?

@oriondean
Copy link
Contributor

There's two approaches you can take to allow users to set a maximum value in finput:

  1. Increase the flexibility of the range option to allow specifying a number of digits a value can be upto.
  2. Adding a setMaxValue option to set a specific number to be the maximum value (e.g. 175,200.00)

Although option 2 provides more choice for end-users, it also comes with a larger increase in complexity. For example, setting a specific maximum value could conflict with other options. You could set a max value that has more decimal digits than what is allowed in range, and you could also set a maximum value that's negative while setting range to be positive numbers only. This is on top of having to perform a value greater-than check before allowing each user input to go through, be it for copy paste or a simple keypress.

Some of this added complexity is also passed down onto the end-user who may not understand why their input is being rejected. More users can deduce when their non-numeric keypress is rejected within a numeric field. On the other hand, despite entering a valid number a keypress could be rejected due to the value reaching some potentially non-obvious (to the user) maximum value.

As a result, I think it'd be nice to have option 1 implemented. I feel it would add support for the vast majority of real-world use cases out there as a bonus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants