Can we use normal Regular Expression Syntax in the Constraint Expression inside Rule Vocabulary? - Forum - Corticon - Progress Community

# Can we use normal Regular Expression Syntax in the Constraint Expression inside Rule Vocabulary?

Forum

#### Can we use normal Regular Expression Syntax in the Constraint Expression inside Rule Vocabulary?

Like If I have to define a new Constraint for PAN no.

For PAN no. following are the generalized rules :

1: First Five characters of the PAN no. will be Alphabets.

2: Next 4 characters will be Digits only.

3: Last Character will be an Alphabet again.

PS: if there is any another way to do that, kindly direct me to that. Or else how do I define such constraints with or without REGEX?

• As far as I know you can't use a regular expression inside a constraint expression in the custom data type (though that would be really nice if you could).
You could just create a normal rule sheet to check that the PAN number conforms.
Something like this
The advantage of doing it in a rule sheet is that you can provide very specific error messages when the PAN does not conform.
Though if the attribute was long this might get rather tedious to create.

Or you can create an extended operator that checks if a string conforms to a regex expression.
Example:
Customer.pan.regex('[A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}')

The code might look something like this
Though this won’t tell you where the error is.

Here’s an example of how regex might be used in a rule sheet:

All Replies
• As far as I know you can't use a regular expression inside a constraint expression in the custom data type (though that would be really nice if you could).
You could just create a normal rule sheet to check that the PAN number conforms.
Something like this
The advantage of doing it in a rule sheet is that you can provide very specific error messages when the PAN does not conform.
Though if the attribute was long this might get rather tedious to create.

Or you can create an extended operator that checks if a string conforms to a regex expression.
Example:
Customer.pan.regex('[A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}')

The code might look something like this
Though this won’t tell you where the error is.

Here’s an example of how regex might be used in a rule sheet:

• Thanks for the answer. Highly obliged sir. Been searching for something like that for days now. Finally, Its sorted out.

• Thanks for your timely reply.This can be tested only when the rules are deployed in the server and can be accessed .Or from Rule Test itself able to test.

Currently i am using corticon Studio 5.5.While developing the rule using corticon studio am able to test this custom regular expression?

If Possible kindly give me the details how the class has been accessed ..

• We followed your process, and completed .

Now, its working fine.

Is there any way to show the constraint validation message?

Please give me the Classes participated in the Corticon Lifecycle.?

• When you create an extended operator it needs to be compiled as a plugin jar file.
This jar file can be used in Studio and it can also be used in Server.

In 5.5 the jar file is com.corticon.eclipse.studio.operations.extended.core_5.5.1.0.jar
For Studio it goes in C:\Corticon 5.5.1\Studio\eclipse\plugins
For Server it goes in the WEB_INF\LIB folder
You will need to restart Studio and Server for the jar file changes to take effect

In 5.6 this process in much easier – you can name the plugin anything you like and then you can include it in your rule project:

Then when you deploy this rule project, the extended operators will be included.

There’s a lot more detail in the help files in Studio:
Look for this section in the results