Validate an input argument in library

Hi Everyone,

I’m creating a reusable library. And am passing a input argument called “Posting Date”

I want the user to enter the date in a specific format. if not the property should show an error right after they enter the data in the posting date property even before the user starts to execute it should show validation error in the filed. Is it possible please guide.

Hey,

Through UiPath apps you can put validation into fields.

However, calling a library though a process, you can put validation on input, workarounds for this:

  1. Either fire a JavaScript as soon as type action is completed by the user.
  2. Or use a trigger as soon as user clicks on a filed so you can run a client side validation function.

Thanks.

Hi @MLT

Try this-

  1. Add validation logic to check the format of the “Posting Date” argument. You can use regular expressions or DateTime parsing methods to validate the format.
  • For example, you can use the DateTime.TryParseExact method to validate the date format against a specific pattern. If the format is incorrect, set a flag or throw an exception to indicate the error.
  1. Error Handling: Handle the error or validation failure within your reusable library. You can use Try-Catch blocks to catch the exception or use conditional statements to check the validation flag.

Thanks!!

Don’t think it’s possible to validate it in design-time (consider variables - the values can’t be known until you run the workflow). Aside if the alternatives posted by @Nitya1, you have the option to accept a DateTime variable as argument (letting the caller handle the parsing).

How are you collecting this input from the user?

If you use UiPath Forms you can create it in the FormFieldsCollection as system.datetime and it’ll automatically make it a date picker field.

It will enforce proper format as you type, or you can use the button to get a calendar picker. You can designate the format in the component properties:

image