universal-dashboard icon indicating copy to clipboard operation
universal-dashboard copied to clipboard

Add -Required switch parameter to UDInputfield

Open HansenRene opened this issue 6 years ago • 1 comments
trafficstars

Is your Enhancement request related to a problem? Please describe

A feature that would come in handy - The ability to specify if input in a field is required before submitting.

Describe the solution you'd like

A simple -Required switch could be added, that forces the end user to enter data in a field before submitting. It could be complemented by a -RequiredText parameter, where one could specify a more detailed error message to be displayed, or left out to simply default to something like "required"

Describe how this would improve your Universal Dashboard Quality of Life

Required fields is a natural thing to have in a form. Today we need to validate the inputs in the endpoints and inform the end user with toasts. This enhancement could simplify that process.

Describe alternatives you've considered

Validating in the endpoint is the g oto method at the moment.

HansenRene avatar Sep 18 '19 13:09 HansenRene

If you aren't using New-UDInputField, you can do this with the param block but it does make sense to do this here. I could see adding a "Validate" script block as well that would get called per field as well.

https://github.com/ironmansoftware/universal-dashboard/blob/master/src/UniversalDashboard.UITest/Integration/Input.Tests.ps1#L150

adamdriscoll avatar Sep 19 '19 00:09 adamdriscoll