finput icon indicating copy to clipboard operation
finput copied to clipboard

Max value

Open stevenjob opened this issue 8 years ago • 1 comments

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?

stevenjob avatar Jul 05 '17 08:07 stevenjob

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.

oriondean avatar Jul 26 '18 13:07 oriondean