Validate Pattern(spaces)

Dear All, am trying to avoiding spaces in the ID attribute field but I cant seem to find how to the correct way to parse the space syntax. Here is the program rule I have tried:
d2:hasValue( ‘client_id’ ) && d2:validatePattern(A{client_id}, ‘""’)
d2:hasValue( ‘client_id’ ) && d2:validatePattern(A{client_id}, ‘* *’)
I have tried both and they are not correct, please help. The id format is as TX9999, if a user enters TX 9999, the system should throw an error.

Hi Muyunda,

are you talking about the auto-generated id patterns? If yes, these patterns doesn’t use the program rule syntax.

If not not, @Markus might be able to help you out with the program rule syntax

Thanks Stian, the ID is not Auto-generated. The user has to enter specific client IDs.

Hey there @WaluQ! The d2:validatePattern uses regular expressions, and the function returns false in case the pattern is not valid.

If your pattern is always “TS” and then 4 digits, try this call: d2:validatePattern(A{client_id}, ‘TS[0-9]{4}’)

I guess you want the error message to show up when there is a client_id entered, and the pattern can not be validated to true. In this case you might want to make this slight modification to the overall expression:
d2:hasValue( ‘client_id’ ) && d2:validatePattern(A{client_id}, ‘TS[0-9]{4}’) == false