[rules-users] how to write regular expressions in drools..

Nagaraju runkana runkana.nagaraju at gmail.com
Fri May 30 05:28:37 EDT 2008


Thanks for replay Chri.

in present product is writting rules validating fields related to table.In
this case i writting diff rules.like this is length rule it's working ...

rule "name.lengthRule:[insert][update][ui]"
 when
  There is an Category
  Category name length is greater than 8
  //CategoryBean($catid:catid,$name:name,$descn:descn)
  //CategoryBean(name != null, eval(name.length() > 8) )
  then
  Reject with response : "name length must be less than 8"
//ruleViolationMap.put(drools.getRule().getName(),"name length must be less
than 80"); if(!isSuppressMode){ drools.halt(); }
end

  now i am trying write diff rules like email,zipcode,credit card....
  i am trying to use regular expressions.In this case negativeTestCases also
Build Success.like this...suppose i am set in to the value like ..
bean.setEmail("@chnati");
in this cases actuly Build failure in our testcases.But,this time also Build
Success.

[*][]Order email address checking for first letter= OrderBean(email matches
"@[A-Za-z0-9]*")

If any possiable give me the related code email,zipcode,phone number.ASAP...

On Fri, May 30, 2008 at 2:15 PM, Christine <christine at christine.nl> wrote:

> Chanti,
> what exactly is your question?
> I think that checking zipcode and credit card formats is easier to do in
> java than with rules. Rules are more efficient in more complex situations,
> like when you have multiple objects that need to meet various conditions.
>
> Christine
>
>
> On Fri, May 30, 2008 09:24, Nagaraju runkana wrote:
> > HI Guys,
> >
> > present i am using drools 4.0 in this case.now, i am writting some rules
> > validation using regular expression ZIPCODE,EMAIL,CREDIT CARD number.like
> > this..
> > --------------------
> > validation.dslr
> > --------------------
> > rule "email.mandatory:[insert][update][ui]"
> >  when
> >   There is an Order
> >   Order email address checking for first letter
> > then
> >  Reject with response : "email address must not start with @ "
> > end
> > rule "phone.mandatory:[insert][update][ui]"
> > when
> >  There is an Order
> >  Order phone number format should checking
> >  then
> >  Reject with response : "The phone number you entered is not valid.Please
> > enter a phone number with the format xxx-xxx-xxxx."\
> > end
> > -----------------------
> > validation.dsl
> > --------------------
> > [*][]Order email address checking for first letter= OrderBean(email
> > matches
> > "@[A-Za-z0-9]*")
> > [*][]Order phone number format should checking=OrderBean( phone not
> > matches
> > "(/\d{3}\-\d{3}\-\d{4}/)==-1)")
> > this rules are not working ...any one can help me.ASAP
> >
> > thanks,
> > chanti
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080530/5bdc901f/attachment.html 


More information about the rules-users mailing list