ironmansoftware / universal-dashboard

Build beautiful websites with PowerShell.
https://universaldashboard.io
GNU Lesser General Public License v3.0
449 stars 85 forks source link

Add -Required switch parameter to UDInputfield #1136

Open PorreKaj opened 5 years ago

PorreKaj commented 5 years ago

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.

adamdriscoll commented 5 years ago

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