Can we use normal Regular Expression Syntax in the Constrain

Posted by Saar Bhatt on 02-Dec-2016 06:02

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? 

Posted by mparish on 02-Dec-2016 07:40

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

Posted by mparish on 02-Dec-2016 07:40

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:
 
 

Posted by Saar Bhatt on 04-Dec-2016 23:53

Thanks [mention:fb7b9369ea3b4efba076d70166fdfbd1:e9ed411860ed4f2ba0265705b8793d05] for the answer. Highly obliged sir. Been searching for something like that for days now. Finally, Its sorted out.

Posted by Saar Bhatt on 05-Dec-2016 01:07

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 ..

Thanks in Advance..

Posted by Saar Bhatt on 05-Dec-2016 01:55

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.?

Posted by mparish on 05-Dec-2016 10:10

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
 

This thread is closed