Search code examples
blueprism

Blue Prism string format / validation


I have a problem where I need to have some exception handling for some data that I will put into a excel report. The DataItem "Personal Identity Code" can be invalid; It must always be 11 characters long and its format should be DDMMYYSNNNX, where DD = day, MM = month, YY = year, S = Either ‘A’ or ‘-‘, NNN = number, X = Letter or number Examples: 310199-111K, 011206A2222

I want to somehow check this / validate the format before it will be processed from the queue (so I can throw an Business Exception). Is there some clever way to set this up? I was thinking about maybe a regex in combination with something?

Edit:

This is how my process page look like with the solution: enter image description here


Solution

  • To validate that kind of input I'd do two validations:

    a) regex to check if it matches the expected format

    Example regex could be this one:

    \d{6}[A-]\d{3}[\d,a-z,A-Z]
    

    or more strict one:

    ^\d{6}[A-]\d{3}[\d,a-z,A-Z]$
    

    B) check if date at the start of the string is valid (e.g. no 30th of February, or 95th of 25th month).

    I'd try to use calculation stage MakeDate() function in combination with Left() and Mid() functions. If the date is incorrect, then the BluePrism will throw an error "Unable to convert the 3 supplied parameters to a date"