Product: PowerShell Universal
Version: 2.6.0
UD 3.8.0
Hey, In the old world with UD v2 I used to be able to put input validation using something similar to this:
New-UDInput -Title "Input Form" -Validate -SubmitText "Create User" -Id "selfservice_input_form_validate" -Endpoint {
param(
[Parameter(Mandatory, HelpMessage = "First name")]
[ValidateNotNullorEmpty()]
[string]$FirstName,
This would not validate on form load or change, so if the field is empty, no errors/validation show, not until you submit - at least thats how I’m remembering it.
In the new world we’re using a -OnValidate scriptblock inside the form element.
This seems to effectivly work like an onchange handler, so its great for validating if something has been input in the right format using regex or such. But not ideal for null/empty/mandatory fields as you’ll end up with validation errors on form load if you use it for that.
So, I’ve resorted instead to using the onsubmit block to check for empty fields and show a ud-toast message in red telling the user a particular empty field is required.
I think, it just doesnt have the same consistency with validation messages sometimes occuring on the form, and othertimes showing as toast messages, and wondered if it was possible to issue validation style error messages on form, via the submit block? bit of a weird question I know and its not causing any issues as there’s a workaround but just curious!
Thanks,
Tom